mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-15 09:13:16 +01:00
Enforce billable rate restriction in controllers and importers instead of model hooks
This commit is contained in:
committed by
Gregor Vostrak
parent
3197c8c7a0
commit
1c41432389
@@ -6,7 +6,6 @@ namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\CustomAuditable;
|
||||
use App\Models\Concerns\HasUuids;
|
||||
use App\Service\BillingContract;
|
||||
use Database\Factories\MemberFactory;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -49,16 +48,6 @@ class Member extends Pivot implements AuditableContract
|
||||
*/
|
||||
protected $table = 'members';
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (Member $member): void {
|
||||
// Organizations that can not use billable rates can not change the billable rate
|
||||
if ($member->billable_rate !== $member->getOriginal('billable_rate') && ! app(BillingContract::class)->canUseBillableRates($member->loadMissing('organization')->organization)) {
|
||||
$member->billable_rate = $member->getOriginal('billable_rate');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user