Files
mareike/app/Models/CostUnit.php

41 lines
929 B
PHP

<?php
namespace App\Models;
use App\Scopes\InstancedModel;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
/**
* @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 tresurers() : BelongsToMany{
return $this->belongsToMany(User::class, 'cost_unit_treasurers', 'cost_unit_id', 'user_id')
->withTimestamps();
}
public function resetTreasurers() {
$this->tresurers()->detach();
$this->save();
}
}