Answers for "update model laravel"

PHP
6

laravel create or update

// 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]
);
Posted by: Guest on September-27-2020
0

laravel model update table

ModelName::whereId($id)->update($request->all());
Posted by: Guest on August-02-2021
1

larave Soft Deletes

Schema::table('flights', function (Blueprint $table) {
    $table->softDeletes();
});
Posted by: Guest on June-12-2020
0

laravel model update table

Post::where('id',3)->update(['title'=>'Updated title']);
Posted by: Guest on October-01-2021
1

update laravel

use App\Models\Flight;

$flight = Flight::find(1);

$flight->name = 'Paris to London';

$flight->save();
Posted by: Guest on March-30-2021
0

laravel model update table

$post = Post::find(3);
$post->title = "Updated title";
$post->save();


or 
  
  
  $affectedRows = Post::where("id", 3)->update(["title" => "Updated title"]);
Posted by: Guest on October-01-2021

Browse Popular Code Answers by Language