I am implementing Laravel Global Scope as documented here but this seems to be not working for me. Below is my line of code in User.php
model
<?php
namespace App;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* The "booted" method of the model.
*
* @return void
*/
protected static function booted()
{
static::addGlobalScope('age', function (Builder $builder) {
$builder->where('age', '>' , 100);
});
}
}
and when I fired User::all()
it only gives me user query as select * from users
Please let me know if I am doing something wrong or missing something here...