46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Scopes\InstancedModel;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* @property string $name
|
|
* @property string $type
|
|
* @property string $billing_deadline
|
|
* @property string $distance_allowance
|
|
* @property boolean $mail_on_new
|
|
* @property boolean $allow_new
|
|
* @property boolean $archived
|
|
* @property Tenant $tenant
|
|
*/
|
|
class CostUnit extends InstancedModel
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'tenant',
|
|
'type',
|
|
'billing_deadline',
|
|
'distance_allowance',
|
|
'mail_on_new',
|
|
'allow_new',
|
|
'archived',
|
|
];
|
|
|
|
public function treasurers() : BelongsToMany{
|
|
return $this->belongsToMany(User::class, 'cost_unit_treasurers', 'cost_unit_id', 'user_id')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function resetTreasurers() {
|
|
$this->treasurers()->detach();
|
|
$this->save();
|
|
}
|
|
|
|
public function invoices() : hasMany {
|
|
return $this->hasMany(Invoice::class);
|
|
}
|
|
}
|