Skip to content

Instantly share code, notes, and snippets.

@IsmailShurrab
Created January 6, 2018 14:58
Show Gist options
  • Save IsmailShurrab/76273dc844730def915c3157a5ad9944 to your computer and use it in GitHub Desktop.
Save IsmailShurrab/76273dc844730def915c3157a5ad9944 to your computer and use it in GitHub Desktop.
EmployeeRestaurant
<?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