'datetime', ]; public function roles(){ return $this->belongsTo(Role::class); } public function locations(){ return $this->hasMany(Location::class); } public function groups(){ return $this->belongsToMany(Group::class); } public function getLastCoordinatesAttribute(){ return self::locations()->orderBy('created_at', 'desc')->first(); } }