Dashboard   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 15 1
1
<?php
2
3
namespace Epesi\Base\Dashboard\Models;
4
5
use atk4\data\Model;
6
use Epesi\Core\Data\HasEpesiConnection;
0 ignored issues
show
Bug introduced by
The type Epesi\Core\Data\HasEpesiConnection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Epesi\Core\System\User\Database\Models\atk4\User;
8
9
class Dashboard extends Model
10
{
11
    use HasEpesiConnection;
12
    
13
    public $table = 'dashboards';
14
    
15
    public function init()
16
    {
17
        parent::init();
18
        
19
        $this->addFields([
20
                'name' => ['type' => 'string'],
21
                'position' => ['type' => 'integer', 'default' => 0]
22
        ]);
23
        
24
        $this->hasOne('user', [User::class, 'our_field' => 'user_id']);
25
        
26
        $this->hasMany('applets', [DashboardApplet::class, 'their_field' => 'dashboard_id']);
27
        
28
        $this->addHook('beforeDelete', function($id) {
29
            $this->withID($id)->ref('applets')->action('delete')->execute();
30
        });
31
    }
32
}
33