Example #1
0
 public function apply(Builder $builder, Model $model)
 {
     // Determine if there's a route to be had
     if (!$model->getRoute() && Request::route() && Request::route()->getName()) {
         // Set the route for the model
         $model->setRoute(Request::route()->getName());
     }
     // Get the scope on the current route
     $scope = Check::getRole()->scope($model->getRoute());
     // Check if the model has the necessary scope
     if ($scope && Base::getModelMethod('restrict', $scope, $model)) {
         return $model->{Base::getModelMethod('restrict', $scope)}($builder);
     }
     return $builder;
 }