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