Entity::creator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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
Bug introduced by
The property module_id does not seem to exist on Uccello\Core\Models\Entity. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
47
    }
48
49
    public function getRecordAttribute()
50
    {
51
        return $this->module->model_class::find($this->record_id);
0 ignored issues
show
Bug introduced by
The property model_class does not seem to exist on Uccello\Core\Models\Module. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
Bug introduced by
The property record_id does not seem to exist on Uccello\Core\Models\Entity. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
52
    }
53
}
54