Dev Diaries WD logo Dev Diaries WD
LARAVEL INTERVIEW · EP 03
LARAVEL INTERVIEW · Episode 03

Laravel: Eloquent ORM (create a record with a model)

Submit a form, and save it to the database the Laravel way

Add Employee
EmployeeController.php
<?php
 /**
     * Store a new employee in the database.
     * We'll write the Eloquent logic for this in the episode.
     */
    public function store(Request $request)
    {
        // TODO (LEP 03): validate the request, then create the record
        // with the Employee model — e.g. Employee::create($request->all());

        $employee = Employee::create($request->all());

        // Employee::create([
        //     'name' => $request->name,
        //     'age' => $request->age
        // ]);

       // return redirect()->url('laravel-interview/lep3_eloquent');
        return redirect('/laravel-interview/lep3_eloquent');
    }

Watch the full episode

Watch on YouTube