laravel eloquent create new record code example
Example 1: laravel delete where
DB::table('users')->where('id', $id)->delete();
Example 2: laravel create or update
$flight = App\Models\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);
Example 3: larave Soft Deletes
Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});
Example 4: laravel model::query
Model::where()->get();
Model::query()->where()->get();
Model::query();
Example 5: create new record via model in laravel
$userData = array('username' => 'Me', 'email' => '[email protected]');
User::create($userData);