laravel compilabile
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
laravel crea o aggiorna
// If there's a flight from Oakland to San Diego, set the price to $99.
// If no matching model exists, create one.
$flight = App\Models\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);
aggiornamento laravel
$flight = App\Models\Flight::find(1);
$flight->name = 'New Flight Name';
$flight->save();
aggiornamento laravel
<!-mass update-->
App\Models\Flight::where('active', 1)
->where('destination', 'San Diego')
->update(['delayed' => 1]);
larave Soft cancella
Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});
php artisan marca modello
php artisan make:model Flight