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

Dashboard::widgets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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