1 | <?php |
||
2 | |||
3 | namespace Uccello\Core\Models; |
||
4 | |||
5 | use Uccello\Core\Database\Eloquent\Model; |
||
6 | |||
7 | class Entity extends Model |
||
8 | { |
||
9 | /** |
||
10 | * The table associated with the model. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $table = 'entities'; |
||
15 | |||
16 | /** |
||
17 | * The attributes that are mass assignable. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $fillable = [ |
||
22 | 'id', |
||
23 | 'module_id', |
||
24 | 'record_id', |
||
25 | 'creator_id', |
||
26 | ]; |
||
27 | |||
28 | protected $primaryKey = 'id'; // TODO: Change to "uid" to make joins withs modules tables possible ??? |
||
29 | public $incrementing = false; |
||
30 | |||
31 | // Allow Eloquent to return id as string instead of int. |
||
32 | protected $casts = ['id' => 'string']; |
||
33 | |||
34 | protected function initTablePrefix() |
||
35 | { |
||
36 | $this->tablePrefix = env('UCCELLO_TABLE_PREFIX', 'uccello_'); |
||
37 | } |
||
38 | |||
39 | public function creator() |
||
40 | { |
||
41 | return $this->belongsTo(User::class); |
||
42 | } |
||
43 | |||
44 | public function getModuleAttribute() |
||
45 | { |
||
46 | return Module::find($this->module_id); |
||
0 ignored issues
–
show
|
|||
47 | } |
||
48 | |||
49 | public function getRecordAttribute() |
||
50 | { |
||
51 | return $this->module->model_class::find($this->record_id); |
||
0 ignored issues
–
show
|
|||
52 | } |
||
53 | } |
||
54 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.