laravel delete

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

showing results for - "laravel delete"
Matthew
25 Feb 2016
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
Santiago
04 Jan 2018
1$flight = Flight::where('number', 'FR 900')->first();
2
3$flight->number = 'FR 456';
4
5$flight->refresh();
6
7$flight->number; // "FR 900"
Noa
11 Apr 2016
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                          ];
Claudio
11 Jul 2017
1// Retrieve flight by name, or create it if it doesn't exist...
2$flight = App\Flight::firstOrCreate(['name' => 'Flight 10']);
3
4// Retrieve flight by name, or create it with the name, delayed, and arrival_time attributes...
5$flight = App\Flight::firstOrCreate(
6    ['name' => 'Flight 10'],
7    ['delayed' => 1, 'arrival_time' => '11:30']
8);
9
10// Retrieve by name, or instantiate...
11$flight = App\Flight::firstOrNew(['name' => 'Flight 10']);
12
13// Retrieve by name, or instantiate with the name, delayed, and arrival_time attributes...
14$flight = App\Flight::firstOrNew(
15    ['name' => 'Flight 10'],
16    ['delayed' => 1, 'arrival_time' => '11:30']
17);
Wilbert
04 May 2019
1DB::table('users')->where('votes', '>', 100)->delete();
Regina
25 Jul 2016
1Flight::destroy(1);
2
3Flight::destroy(1, 2, 3);
4
5Flight::destroy([1, 2, 3]);
6
7Flight::destroy(collect([1, 2, 3]));
similar questions
queries leading to this page
laravel delete