mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-14 00:33:17 +01:00
add billable rate restriction for free organizations
This commit is contained in:
@@ -6,6 +6,7 @@ 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;
|
||||
@@ -48,6 +49,16 @@ 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