widget refactoring
This commit is contained in:
@ -25,16 +25,16 @@ class Dashboard extends Model
|
||||
*/
|
||||
public $sortable = ['name', 'enabled'];
|
||||
|
||||
public function widgets()
|
||||
{
|
||||
return $this->hasMany('App\Models\Common\Widget')->orderBy('sort', 'asc');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Auth\User', 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function widgets()
|
||||
{
|
||||
return $this->hasMany('App\Models\Common\Widget')->orderBy('sort', 'asc');
|
||||
}
|
||||
|
||||
public function scopeOfUser($query, $user_id)
|
||||
{
|
||||
return $query->where('user_id', $user_id);
|
||||
|
@ -31,4 +31,9 @@ class Widget extends Model
|
||||
{
|
||||
return $this->belongsTo('App\Models\Common\Dashboard');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOneThrough('App\Models\Auth\User', 'App\Models\Common\Dashboard');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user