Issues (18)

src/Dashboard/Models/Dashboard.php (1 issue)

Labels
Severity
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
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