📜  范围示例 laravel 8 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:01.935000             🧑  作者: Mango

代码示例1
// in your model
public function scopeField($query)
    {
        return $query->where('field', 'value'); //  if in header return $query->where('field', request()->field);
    }

// in your controller or repository 
    public function index()
    {
        return Package::field()->get();
    }