Answers for "how to update data using model in laravel"

PHP
0

laravel model update table

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

create new record via model in laravel

$userData = array('username' => 'Me', 'email' => '[email protected]');
User::create($userData);
Posted by: Guest on October-19-2020
0

Laravel inserting and updating models

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Flight;
use Illuminate\Http\Request;

class FlightController extends Controller
{
    /**
     * Store a new flight in the database.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        // Validate the request...

        $flight = new Flight;

        $flight->name = $request->name;

        $flight->save();
    }
}
Posted by: Guest on July-24-2021

Code answers related to "how to update data using model in laravel"

Browse Popular Code Answers by Language