Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dirk313's avatar

Laravel CRUD

Hi all I am n newbie in Laravel and have started to create my own application, I would like to know if there is a shorter way in creating CRUD functions with the correct validations in doing create, store, update, delete. I'm struggling to find the right way of doing this , I know some video content can be misleading and you get the shortcut versions, but I would like to do it the right way from the start, Please see my Code

{

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function createEmployee()
{
    employee::create([
        'name'=> request()->name,
        'lastname'=>request()->lastname,
        'address'=>request()->address,
        'email'=>request()->email,
        'jobtitle'=>request()->jobtitle,
    ]);
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function storeEmployee(Request $request)
{
    $validated = $request->validate([
        'name' => 'required|max:50',
        'lasname' => 'required|max:50',
        'address' => 'required|max:50',
        'email' => 'required|email|unique:email',
        'jobtitle' => 'required|max:50'

    ]);

}

Not sure how to do the update and delete

0 likes
7 replies
sr57's avatar

I suggest you to follow an example from the web, there are many, just be sure, if you begin with Laravel, to choose one from the same version of Laravel you use (or install the Laravel version from the example)

Dirk313's avatar

Wow that will help allot, thank you for the information, and I will make sure to follow it accordingly, its very tricky when your new to this : ) I will study the links you shared

siangboon's avatar

there is no right or wrong, just to get the works done first... refactor it when you learned or found a better way, this is part of the development...

btw, once you validated, the $validated can simply pass to the create method...

1 like
Dirk313's avatar

Thank you so much for you comment, Its highly appreciated, and yea I need to get a cleaner way for my code hehe

Please or to participate in this conversation.