1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | |||
4 | namespace BristolSU\ControlDB\Models; |
||
5 | |||
6 | |||
7 | use BristolSU\ControlDB\AdditionalProperties\HasAdditionalProperties; |
||
8 | use BristolSU\ControlDB\Traits\DataRoleTrait; |
||
9 | use DateTime; |
||
10 | use Illuminate\Database\Eloquent\Model; |
||
11 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
12 | |||
13 | /** |
||
14 | * Handles attributes belonging to a role |
||
15 | */ |
||
0 ignored issues
–
show
|
|||
16 | class DataRole extends Model implements \BristolSU\ControlDB\Contracts\Models\DataRole |
||
17 | { |
||
18 | use SoftDeletes, HasAdditionalProperties, DataRoleTrait { |
||
19 | setRoleName as baseSetRoleName; |
||
20 | setEmail as baseSetEmail; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * The table to use |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $table = 'control_data_role'; |
||
29 | |||
30 | /** |
||
31 | * Fillable attributes |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $fillable = [ |
||
36 | 'role_name', 'email' |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * Get the ID of the role |
||
41 | * |
||
42 | * @return int |
||
43 | */ |
||
44 | 25 | public function id(): int |
|
45 | { |
||
46 | 25 | return $this->id; |
|
47 | } |
||
48 | |||
49 | |||
50 | |||
51 | /** |
||
52 | * Get the email of the role |
||
53 | * |
||
54 | * @return string|null |
||
55 | */ |
||
56 | 9 | public function email(): ?string |
|
57 | { |
||
58 | 9 | return $this->email; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * Get the name for the role |
||
63 | * |
||
64 | * @return string|null |
||
65 | */ |
||
66 | 9 | public function roleName(): ?string |
|
67 | { |
||
68 | 9 | return $this->role_name; |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * Set the email of the role |
||
73 | * |
||
74 | * @param string|null $email |
||
0 ignored issues
–
show
|
|||
75 | */ |
||
0 ignored issues
–
show
|
|||
76 | 2 | public function setEmail(?string $email): void |
|
77 | { |
||
78 | 2 | $this->baseSetEmail($email); |
|
79 | 2 | $this->refresh(); |
|
80 | 2 | } |
|
81 | |||
82 | /** |
||
83 | * Set a name for the role |
||
84 | * |
||
85 | * @param string|null $roleName |
||
0 ignored issues
–
show
|
|||
86 | */ |
||
0 ignored issues
–
show
|
|||
87 | 2 | public function setRoleName(?string $roleName): void |
|
88 | { |
||
89 | 2 | $this->baseSetRoleName($roleName); |
|
90 | 2 | $this->refresh(); |
|
91 | 2 | } |
|
92 | |||
93 | |||
94 | } |