Cost units can be edited

This commit is contained in:
2026-02-08 20:06:38 +01:00
parent 6fc65e195c
commit bccfc11687
53 changed files with 2021 additions and 29 deletions

View File

@@ -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();
}
}