abdulaziz
10 months ago

How to avoid repeating yourself

Posted 10 months ago by abdulaziz

I want to have this:

    public function show(User $user)
    {
    //
    }

    public function edit(User $user)
    {
        //
    }

    public function update(Request $request,User $user)
    {
        //
    }

    public function destroy(User $user)
    {
        //
    }

Instead of this:

    public function show($id)
    {
        $user = User::find($id);
        //
    }

    public function edit($id)
    {
        $user = User::find($id);
        //
    }
    public function update(Request $request, $id)
    {
        $user = User::find($id);
        //
    }
    public function destroy($id)
    {
        $user = User::find($id);
        //
    }

How to achieve this functionality please help. Thank you!

Please sign in or create an account to participate in this conversation.