Created
January 6, 2018 14:58
-
-
Save IsmailShurrab/76273dc844730def915c3157a5ad9944 to your computer and use it in GitHub Desktop.
EmployeeRestaurant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use Illuminate\Notifications\Notifiable; | |
use Illuminate\Foundation\Auth\User as Authenticatable; | |
class EmployeeRestaurant extends Authenticatable | |
{ | |
protected $casts = [ | |
'city_id' => 'int', | |
'is_agent' => 'bool', | |
]; | |
protected $appends = ['full_name']; | |
protected $fillable = [ | |
'uuid', | |
'name', | |
'first_name', | |
'last_name', | |
'city_id', | |
'restaurant_id', | |
'email', | |
'password', | |
'mobile', | |
'api_token', | |
'remember_token', | |
'is_Admin', | |
'status' | |
]; | |
public function city() | |
{ | |
return $this->belongsTo(City::class); | |
} | |
public function restaurant() | |
{ | |
return $this->belongsTo(Restaurant::class); | |
} | |
public function getFullNameAttribute() | |
{ | |
return $this->first_name.' '.$this->last_name; | |
} | |
public function setPasswordAttribute($value) | |
{ | |
if(!is_null($value)){ | |
if( \Hash::needsRehash($value) ) { | |
$value = bcrypt($value); | |
} | |
$this->attributes['password'] = $value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment