*/ protected $fillable = [ 'name', 'email', 'password', 'role', 'phone_number', 'address', 'avatar' ]; /** * 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 getAvatarImageAttribute() { if ($this->avatar) { return asset('storage/' . $this->avatar); } else { return asset('assets/images/defaultAvatar.png'); } } public function getJoinedSinceAttribute() { $join_date = $this->created_at ? Carbon::parse($this->created_at)->locale('id')->isoFormat('D MMMM Y') : Carbon::parse(now())->locale('id')->isoFormat('D MMMM Y'); return $join_date; } public function getRoleNameAttribute() { if($this->role == 1){ return 'Admin'; } else { return 'Mitra Panen'; } } public function ponds() { return $this->hasMany(Pond::class, 'user_id'); } }