1

enter image description here

here is my database table I want to work with I want to update the participation column of form_submissions table with boolean 1 by using the user_id

here is mycontroller

 public function update($id)
    {
        $submission = Form_Submission::find($id);
        $submission->participation=1;
        $submission->save();
        return back();
    {

I got the user_id from the link using a button and passed it to the function can someone tell me how I can update the above record using user_id?

1 Answer 1

1

Having user_id, you can retrieve that specific Form_Submission using where, like this:

Form_Submission::where('user_id', $user_id)->get();

Resource for this: https://laravel.com/docs/7.x/queries#where-clauses

Also, to update it, you can use where - update, like this:

Form_Submission::where('user_id', $user_id)->update(['participation' => 1]);

Resource for this: https://laravel.com/docs/7.x/queries#updates

Hope this helps!

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.