*/ protected $fillable = [ 'name', 'email', 'mobile', 'password', 'type', 'firebase_id', 'profile', 'address', 'notification', 'country_code', 'show_personal_details', 'is_verified', 'auto_approve_item', 'region_code' ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function getProfileAttribute($image) { if (!empty($image) && !filter_var($image, FILTER_VALIDATE_URL)) { return url(Storage::url($image)); } return $image; } public function items() { return $this->hasMany(Item::class); } public function sellerReview() { return $this->hasMany(SellerRating::class , 'seller_id'); } public function scopeSearch($query, $search) { $search = "%" . $search . "%"; return $query->where(function ($q) use ($search) { $q->orWhere('email', 'LIKE', $search) ->orWhere('mobile', 'LIKE', $search) ->orWhere('name', 'LIKE', $search) ->orWhere('type', 'LIKE', $search) ->orWhere('notification', 'LIKE', $search) ->orWhere('firebase_id', 'LIKE', $search) ->orWhere('address', 'LIKE', $search) ->orWhere('created_at', 'LIKE', $search) ->orWhere('updated_at', 'LIKE', $search); }); } public function user_reports() { return $this->hasMany(UserReports::class); } public function fcm_tokens() { return $this->hasMany(UserFcmToken::class); } public function getStatusAttribute($value) { if ($this->deleted_at) { return "inactive"; } if ($this->expiry_date && $this->expiry_date < Carbon::now()) { return "expired"; } return $value; } }