primaryKey; // // return Cache::remember($cacheKey, 10, function () { // return $this->roles()->get(); // }*/ // return $this->roles()->get(); // // } // public function canDo($permission, $requireAll = false) { if (is_array($permission)) { foreach ($permission as $permName) { $hasPerm = $this->canDo($permName); if ($hasPerm && !$requireAll) { return true; } elseif (!$hasPerm && $requireAll) { return false; } } return $requireAll; } else { foreach ($this->cachedRoles() as $role) { // Validate against the Permission table foreach ($role->cachedPermissions() as $perm) { if (strtolower($permission) == strtolower($perm->title)) { return true; } } } } return false; } // // public function hasRole($name) // { // foreach ($this->roles()->get() as $role) // { // if (strtolower($role->title)===strtolower($name)) // { // return true; // } // } // return false; // } /////////////////////////////////////////////////////////////////// public function images() { return $this->morphToMany('App\Gallery', 'uploadable'); } public function offers() { return $this->hasMany('App\Offer'); } public function shopping_carts() { return $this->hasMany('App\ShoppingCart'); } public function businesses() { return $this->hasMany('App\Business'); } public function business_items() { return $this->hasMany('App\BusinessItem'); } public function feedbacks() { return $this->hasMany('App\Feedback'); } public function active_business() { return $this->belongsTo('App\Business', 'last_used_business'); } public function buys() { return $this->hasMany('App\Order', 'buyer_id'); } public function sells() { return $this->hasMany('App\Order', 'seller_id'); } public function files() { return $this->hasMany('App\Gallery')->where('business_id', null); } public function orginalProfile() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Profile')->where('parent_id', null); } public function Profile() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Profile')->where('parent_id', null); } public function addresses() { return $this->morphMany('App\Address', 'addressable'); } public function introducer() { return $this->belongsTo('App\User', 'introducer_id', 'id'); } public function send_conversations() { return $this->hasMany('App\Conversation', 'sender_id'); } public function recieve_conversations() { return $this->hasMany('App\Conversation', 'receiver_id'); } public function reservations() { return $this->hasMany('App\Reservation'); } public function likes() { return $this->hasMany('App\Like'); } // public function files() // { // return $this->hasMany() // } public static function MakeDetail(){ return json_encode (['NationalCode' , 'ParentName' , 'Educational' , 'PlaceBirth']); } public function setBirthdayAttribute($value) { $carbon = new Carbon(); $date = substr($value, 0, -3); $date = $carbon->timestamp($date)->timezone('Asia/Tehran')->toDateString(); $this->attributes['birthday'] = $date; } public function frames() { return $this->belongsToMany('App\\SpFrame', 'sp_frame_user')->withPivot('action')->withTimestamps(); } }