Answers for "laravel with trashed"

PHP
9

laravel update from query

$affected = DB::table('users')
              ->where('id', 1)
              ->update(['votes' => 1]);
Posted by: Guest on May-07-2020
0

laravel with trashed

$flights = App\Flight::withTrashed()
                ->where('account_id', 1)
                ->get();
Posted by: Guest on April-08-2020
4

laravel firstorcreate

// Retrieve flight by name, or create it if it doesn't exist...
$flight = App\Flight::firstOrCreate(['name' => 'Flight 10']);

// Retrieve flight by name, or create it with the name, delayed, and arrival_time attributes...
$flight = App\Flight::firstOrCreate(
    ['name' => 'Flight 10'],
    ['delayed' => 1, 'arrival_time' => '11:30']
);

// Retrieve by name, or instantiate...
$flight = App\Flight::firstOrNew(['name' => 'Flight 10']);

// Retrieve by name, or instantiate with the name, delayed, and arrival_time attributes...
$flight = App\Flight::firstOrNew(
    ['name' => 'Flight 10'],
    ['delayed' => 1, 'arrival_time' => '11:30']
);
Posted by: Guest on June-08-2020
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 query with trashed

$user->roles()->withTrashed()->get();
Posted by: Guest on June-19-2020

Browse Popular Code Answers by Language