%PDF- %PDF-
Direktori : /var/www/html/news/app/Models/ |
Current File : /var/www/html/news/app/Models/User.php |
<?php namespace App\Models; use App\Presenters\UserPresenter; use Carbon\Carbon; use HttpOz\Roles\Contracts\HasRole as HasRoleContract; use HttpOz\Roles\Traits\HasRole; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laracodes\Presenter\Traits\Presentable; use Watson\Rememberable\Rememberable; class User extends Authenticatable implements HasRoleContract { use Notifiable, Rememberable, HasRole, Presentable; const ROLE_SLUG_ADMIN = 'admin'; const ROLE_SLUG_BACKOFFICE = 'backoffice'; const ROLE_SLUG_EDITOR = 'editor'; const ROLE_SLUG_VISITOR = 'visitor'; protected $presenter = UserPresenter::class; protected $fillable = [ 'email', 'name', 'surname', 'password', 'birthdate', 'is_active' ]; protected $hidden = [ 'password', 'remember_token' ]; protected $casts = [ 'id' => 'integer', 'email' => 'string', 'name' => 'string', 'surname' => 'string', 'birthdate' => 'date', 'is_active' => 'boolean' ]; protected $dates = [ 'birthdate' ]; /** * @param $value * @return string */ public function getCreatedAtAttribute($value) { return Carbon::parse($value)->toIso8601String(); } /** * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function media() { return $this->morphOne(Media::class, 'mediable'); } /** * @param $value * @return string */ public function getUpdatedAtAttribute($value) { return Carbon::parse($value)->toIso8601String(); } public function setPasswordAttribute($value) { $this->attributes['password'] = bcrypt($value); } public function setBirthdateAttribute($value) { $this->attributes['birthdate'] = Carbon::parse($value); } }