Cost units can be edited
This commit is contained in:
40
app/Models/CostUnit.php
Normal file
40
app/Models/CostUnit.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user