заполняемый laravel
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
laravel създава или обновява
// 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]
);
актуализация laravel
$flight = App\Models\Flight::find(1);
$flight->name = 'New Flight Name';
$flight->save();
актуализация laravel
<!-mass update-->
App\Models\Flight::where('active', 1)
->where('destination', 'San Diego')
->update(['delayed' => 1]);
меко премахване на larave
Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});
php един майстор прави модел
php artisan make:model Flight