-
app/Models/Common/Dashboard.php
Open in GitHubuse App\Abstracts\Model; class Dashboard extends Model { // public function scopeUserId($query, $user_id) { return $query->whereHas('users', function ($query) use ($user_id) { $query->where('user_id', $user_id); }); } public function scopeAlias($query, $alias) { $class = ($alias == 'core') ? 'App\\\\' : 'Modules\\\\' . Str::studly($alias) . '\\\\'; return $query->whereHas('widgets', function ($query) use ($class) { $query->where('class', 'like', $class . '%'); })->whereDoesntHave('widgets', function ($query) use ($class) { $query->where('class', 'not like', $class . '%'); }); } // }