Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

scope sample laravel 8

// 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();
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #scope #sample #laravel
ADD COMMENT
Topic
Name
2+7 =