1 | <?php |
||
2 | |||
3 | namespace Uccello\Core\Models; |
||
4 | |||
5 | use Uccello\Core\Database\Eloquent\Model; |
||
6 | |||
7 | class Capability extends Model |
||
8 | { |
||
9 | /** |
||
10 | * The table associated with the model. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $table = 'capabilities'; |
||
15 | |||
16 | /** |
||
17 | * The attributes that should be casted to native types. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $casts = [ |
||
22 | 'data' => 'object', |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * The attributes that are mass assignable. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $fillable = [ |
||
31 | 'name', |
||
32 | 'data', |
||
33 | ]; |
||
34 | |||
35 | protected function initTablePrefix() |
||
36 | { |
||
37 | $this->tablePrefix = env('UCCELLO_TABLE_PREFIX', 'uccello_'); |
||
38 | } |
||
39 | |||
40 | public function permissions() |
||
41 | { |
||
42 | return $this->hasMany(Permission::class); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Returns module package name |
||
47 | * |
||
48 | * @return string|null |
||
49 | */ |
||
50 | public function getPackageAttribute() : ?string |
||
51 | { |
||
52 | $package = ''; // For modules created directory in the host application |
||
53 | |||
54 | // Get only package name if defined (Format: vendor/package) |
||
55 | if (isset($this->data->package)) |
||
0 ignored issues
–
show
|
|||
56 | { |
||
57 | $packageData = explode('/', $this->data->package); |
||
58 | $package = array_pop($packageData); |
||
59 | } |
||
60 | |||
61 | return $package; |
||
62 | } |
||
63 | } |
||
64 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.