Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Group | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
privileges | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
users | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Engelsystem\Models; |
6 | |
7 | use Engelsystem\Models\User\User; |
8 | use Illuminate\Database\Eloquent\Builder; |
9 | use Illuminate\Database\Eloquent\Collection; |
10 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
11 | use Illuminate\Database\Eloquent\Relations\BelongsToMany; |
12 | |
13 | /** |
14 | * @property int $id |
15 | * @property string $name |
16 | * |
17 | * @property-read Collection|Privilege[] $privileges |
18 | * @property-read Collection|User[] $users |
19 | * |
20 | * @method static Builder|Group whereId($value) |
21 | * @method static Builder|Group whereName($value) |
22 | */ |
23 | class Group extends BaseModel |
24 | { |
25 | use HasFactory; |
26 | |
27 | /** @var string[] */ |
28 | protected $fillable = [ // phpcs:ignore |
29 | 'name', |
30 | ]; |
31 | |
32 | public function privileges(): BelongsToMany |
33 | { |
34 | return $this->belongsToMany(Privilege::class, 'group_privileges'); |
35 | } |
36 | |
37 | public function users(): BelongsToMany |
38 | { |
39 | return $this->belongsToMany(User::class, 'users_groups'); |
40 | } |
41 | } |