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