ここに記載されているように Laravel Global Scope を実装していますが、これはうまくいかないようです。以下はUser.php
モデルの私のコード行です
<?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);
});
}
}
そして私が解雇したとき、User::all()
それは私にユーザークエリを与えるだけですselect * from users
ここで何か間違ったことをしている、または何かが欠けている場合はお知らせください...