Cost units can be edited
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
@@ -95,7 +96,7 @@ class User extends Authenticatable
|
||||
public function getFullname() : string {
|
||||
return sprintf('%1$1s %2$s %3$s',
|
||||
$this->firstname,
|
||||
$this->nickname !== '' ? '(' . $this->nickname . ')' : '',
|
||||
$this->nickname !== null ? '(' . $this->nickname . ')' : '',
|
||||
$this->lastname
|
||||
);
|
||||
}
|
||||
@@ -103,4 +104,14 @@ class User extends Authenticatable
|
||||
public function getNicename() : string {
|
||||
return $this->nickname ?? $this->firstname;
|
||||
}
|
||||
|
||||
public function localGroup() : Tenant {
|
||||
return $this->belongsTo(Tenant::class, 'local_group', 'slug')->first();
|
||||
}
|
||||
|
||||
public function costUnits()
|
||||
{
|
||||
return $this->belongsToMany(CostUnit::class, 'cost_unit_treasurers', 'user_id', 'cost_unit_id')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user