File size: 530 Bytes
5f32fbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace App\Rules\Team;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;

class TeamInviteRule implements ValidationRule
{
    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        $team = request()->route('team');

        $allow_seats = $team->allow_seats;

        $used_seats = $team->members()->count();

        if ($allow_seats <= $used_seats) {
            $fail(__('You have reached the maximum number of seats allowed for this team.'));
        }
    }
}