mimiloca
1 week ago
198
12
Eloquent

How do I pass user_id for updating perpose in admin page?

Posted 1 week ago by mimiloca

i'm creating update method to update user application status. This is in 1- M relationship. but I'm getting error with General error: 1364 Field 'user_id' doesn't have a default value

then i realized that i dont pass the user value so i want to put this method $application->user_id = $request->input('user_id') ; How to put that method or pass the user_id ? So admin can update the user application status.

edit.blade

<form class="form-horizontal" action="{{route('application.update')}}" method="POST" >
 public function edit($id)
    {
        
        $applications = Application::with('user')->find($id);

        return view('application.edit')->with('application', $applications);
    }


  public function update(Request $request)
    {
        $this->validate($request,[

            'status' =>'required',
        ]);

        $applications = new Application;
        $applications->status = $request->input('status');
        $applications->save();
       
        return redirect('/application/view')->with('Success', 'Status updated!');
    }

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