laravel scope

Solutions on MaxInterview for laravel scope by the best coders in the world

showing results for - "laravel scope"
Roberta
08 Sep 2019
1# The easiest way to create a model instance is using the 
2# make:model Artisan command:
3
4php artisan make:model Flight
5
6# If you would like to generate a database migration when you 
7# generate the model, you may use the --migration or -m option:
8
9php artisan make:model Flight --migration
10php artisan make:model Flight -m
Elisa
22 Jan 2017
1    /**
2     * The attributes that are mass assignable.
3     */
4    protected $fillable = [
5      					   'title',
6                           'slug',
7                           'body',
8                           'image',
9                           'published',
10                           'comments_open'
11                          ];
Luis
07 May 2020
1class User extends Model {
2
3    public function scopePopular($query)
4    {
5        return $query->where('votes', '>', 100);
6    }
7
8    public function scopeWomen($query)
9    {
10        return $query->whereGender('W');
11    }
12
13}
Matteo
03 Jun 2017
1php artisan make:model Flight
Angela
26 Oct 2019
1// If there's a flight from Oakland to San Diego, set the price to $99.
2// If no matching model exists, create one.
3$flight = App\Models\Flight::updateOrCreate(
4    ['departure' => 'Oakland', 'destination' => 'San Diego'],
5    ['price' => 99, 'discounted' => 1]
6);
Gaia
30 Mar 2018
1public function apply(Builder $builder, Model $model)
2    {
3        $builder->where('age', '>', 200);
4    }
similar questions
queries leading to this page
laravel scope