Completed
Push — misc ( 5d788f...8599dc )
by Tony
02:45
created

Dashboard   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A widgets() 0 4 1
A scopeAllAvailable() 0 5 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
8
class Dashboard extends Model
9
{
10
    /**
11
     * The table associated with the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'dashboards';
16
17
    /**
18
     * The primary key column name.
19
     *
20
     * @var string
21
     */
22
    protected $primaryKey = 'dashboard_id';
23
24
    /**
25
     * Indicates if the model should be timestamped.
26
     *
27
     * @var bool
28
     */
29
    public $timestamps = false;
30
31
    protected $fillable = ['user_id', 'dashboard_name', 'access'];
32
33
    public function widgets()
34
    {
35
        return $this->hasMany('App\Models\UsersWidgets', 'dashboard_id');
36
    }
37
38
    public function scopeAllAvailable($query, $user_id)
39
    {
40
        return $query->where('user_id', $user_id)
41
                    ->orWhere('access', '>', 0);
42
    }
43
44
}
45