1 | <?php |
||
2 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | namespace BristolSU\ControlDB\Models; |
||
4 | |||
5 | use BristolSU\ControlDB\Traits\GroupTrait; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
8 | |||
9 | /** |
||
10 | * Represents a group |
||
11 | */ |
||
0 ignored issues
–
show
|
|||
12 | class Group extends Model implements \BristolSU\ControlDB\Contracts\Models\Group |
||
13 | { |
||
14 | use SoftDeletes, GroupTrait { |
||
15 | setDataProviderId as baseSetDataProviderId; |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * Table to use |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $table = 'control_groups'; |
||
24 | |||
25 | /** |
||
26 | * Fillable attributes |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $fillable = ['data_provider_id']; |
||
31 | |||
32 | /** |
||
33 | * Attributes to append when casting to an array |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $appends = [ |
||
38 | 'data' |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * ID of the group |
||
43 | * |
||
44 | * @return int |
||
45 | */ |
||
46 | 66 | public function id(): int |
|
47 | { |
||
48 | 66 | return $this->id; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * ID of the data provider for the group |
||
53 | * |
||
54 | * @return int |
||
55 | */ |
||
56 | 19 | public function dataProviderId(): int |
|
57 | { |
||
58 | 19 | return $this->data_provider_id; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * Laravel integration for a data property |
||
63 | * |
||
64 | * @return \BristolSU\ControlDB\Contracts\Models\DataGroup |
||
65 | */ |
||
66 | 10 | public function getDataAttribute(): \BristolSU\ControlDB\Contracts\Models\DataGroup |
|
67 | { |
||
68 | 10 | return $this->data(); |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * Set the ID of the data provider |
||
73 | * |
||
74 | * @param int $dataProviderId |
||
0 ignored issues
–
show
|
|||
75 | */ |
||
0 ignored issues
–
show
|
|||
76 | 2 | public function setDataProviderId(int $dataProviderId): void |
|
77 | { |
||
78 | 2 | $this->baseSetDataProviderId($dataProviderId); |
|
79 | 2 | $this->refresh(); |
|
80 | 2 | } |
|
81 | |||
82 | |||
83 | } |
||
84 |