Skip to content

Instantly share code, notes, and snippets.

@tanftw
Created October 23, 2015 18:13
Show Gist options
  • Save tanftw/af7953f31d0ddd532db9 to your computer and use it in GitHub Desktop.
Save tanftw/af7953f31d0ddd532db9 to your computer and use it in GitHub Desktop.
Student scope
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\ScopeInterface;
class StudentScope implements ScopeInterface
{
public function apply(Builder $builder, Model $model)
{
$builder->whereRoleId(2);
}
public function remove(Builder $builder, Model $model)
{
// you don't need this
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment