1, 'female' => 2, ]; /** * The attributes that are mass assignable. * * @var array */ protected $guarded = []; /** * 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', ]; protected $appends = [ 'full_name' ]; public function getFullNameAttribute() { return $this->first_name . ' ' . $this->last_name; } public function getAvatarAttribute() { return isset($this->attributes['avatar']) ? url($this->attributes['avatar']) : null; } public function setPasswordAttribute($password) { $this->attributes['password'] = Hash::make($password); } public function otpTokens() { return $this->hasMany(OtpTokens::class); } public function transactions() { return $this->hasMany(Transaction::class); } public function packageNames() { return $this->belongsToMany(PackageName::class, 'user_package_name')->withPivot(['id', 'tries','fcm_token'])->withTimestamps(); } public function products() { return $this->belongsToMany(Product::class, 'user_product')->withPivot(['expire_at', 'purchase_token', 'gateway'])->withTimestamps(); } protected function serializeDate(DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } public function plans() { return $this->hasMany(Plan::class); } // public function response() // { // return $this->hasOne(UserResponse::class); // } public function breathingExercises() { return $this->hasMany(BreathingExercise::class); } }