check() && $this->likes()->get()) { foreach ($this->likes()->get() as $like) { if (auth()->user()->id === $like->user_id) return true; } return false; } return false; } public function setDetailsAttribute($value) { $this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE); } public function setFeaturesAttribute($value) { $this->attributes['features'] = json_encode($value, JSON_UNESCAPED_UNICODE); } public function setPhonesAttribute($value) { $this->attributes['phones'] = json_encode($value, JSON_UNESCAPED_UNICODE); } public function getPhonesAttribute() { return json_decode($this->attributes['phones']); } public function getDetailsAttribute() { $details = json_decode($this->attributes['details']); if ($details and isset($details->PaymentMethods)) { $configMethods = config('SPconf.PaymentMethods'); $methods = []; foreach ($details->PaymentMethods as $PaymentMethod) { if (array_has($configMethods, $PaymentMethod)) { $methods[$PaymentMethod] = $configMethods[$PaymentMethod]; } } $details->PaymentMethods = $methods; } return $details; } public function getFeaturesAttribute() { return json_decode($this->attributes['features']); } public function business_items() { return $this->hasMany('App\BusinessItem'); } public function verified_business_items() { return $this->hasMany('App\BusinessItem')->where('verification', 1); } public function portfolios() { return $this->hasMany('App\Portfolio'); } public function contact_messages() { return $this->hasMany('App\ContactMessage'); } public function reservations() { return $this->hasMany('App\Reservation'); } public function business_title() { return $this->belongsTo('App\BusinessTitle'); } public function addresses() { return $this->morphMany('App\Address', 'addressable'); } public function user() { return $this->belongsTo('App\User'); } public function categories() { return $this->belongsToMany('App\Category')->withTimestamps(); } public function category() { return $this->belongsTo('App\Category'); } public function shopping_carts() { return $this->hasMany('App\ShoppingCart'); } public function orders() { return $this->hasMany('App\Order'); } public function city() { return $this->belongsTo('App\City'); } public function district() { return $this->belongsTo('App\District'); } public function data() { return $this->hasMany('App\Data'); } public function template() { return $this->hasMany('App\SpUserTemplate'); } public function user_templates() { return $this->hasMany('App\SpUserTemplate'); } public function tags() { return $this->morphToMany('App\Tag', 'taggable'); } public function news() { return $this->hasMany('App\News'); } public function likes() { return $this->morphMany('App\Like', 'likeable'); } public function toSearchableArray() { return [ 'id' => $this->id, 'brand_en' => $this->brand_en, 'brand_fa' => $this->brand_fa, 'city_id' => $this->city_id, ]; } /** * Get all of the post's comments. */ public function comments() { return $this->morphMany('App\Comment', 'commentable')->orderBy('updated_at', 'desc'); } public function feedbacks() { return $this->morphMany('App\Feedback', 'feedbackable')->orderBy('updated_at', 'desc'); } public function members() { return $this->belongsToMany('App\user', 'business_has_user', 'business_id', 'user_id'); } public function orginalImages() { return $this->morphToMany('App\Gallery', 'uploadable'); } public function images() { return $this->morphToMany('App\Gallery', 'uploadable'); } public function files() { return $this->hasMany('App\Gallery')->where('parent_id', null); } public function gallery() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null); } public function title_image() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null); } public function orginalLogo() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null); } public function logo() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'logo')->where('parent_id', null); } public function orginalBanner() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'banner')->where('parent_id', null); } public function banner() { return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'banner')->where('parent_id', null); } public function special_content_options() { return $this->morphMany('App\SpecialContentOption', 'special_content_optionable'); } public function social_media() { return $this->hasOne('App\SocialMedia'); } public function events() { return $this->hasMany('App\Event'); } public function attributes() { return $this->belongsToMany('App\Attribute'); } }