Answers for "eloquent delete in laravel"

PHP
5

force delete soft delete laravel

Soft Delete : $user->delete();
Force Delete : $user->forceDelete();
Restore Soft Deleted Item : $user->restore();
Posted by: Guest on August-14-2020
1

laravel delete

DB::table('users')->where('votes', '>', 100)->delete();
Posted by: Guest on March-11-2021
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
2

laravel eloquent remove from db

public function destroy($id){

  $res=User::find($id)->delete();
  if ($res){
    $data=[
    'status'=>'1',
    'msg'=>'success'
  ];
  }else{
    $data=[
    'status'=>'0',
    'msg'=>'fail'
  ];
  return response()->json($data);
Posted by: Guest on November-05-2020
4

laravel update

$flight = App\Models\Flight::find(1);

$flight->name = 'New Flight Name';

$flight->save();
Posted by: Guest on September-25-2020

Code answers related to "eloquent delete in laravel"

Browse Popular Code Answers by Language