Home > Software design >  Missing required parameter for [Route: Oeuvre.update]
Missing required parameter for [Route: Oeuvre.update]

Time:05-11

enter image description here

My update function in the resource controller

public function update(UpdateOeuvreRequest $request, Oeuvre $oeuvre)
    {
     
        $oeuvre->titre = $request->input('titre');
        $oeuvre->auteur = $request->input('auteur');
        $oeuvre->annee = $request->input('annee');
        $oeuvre->description = $request->input('description');
        $oeuvre->category_id = $request->input('category_id');
        $oeuvre->qt = $request->input('qt');
        $query=$oeuvre->save();
        if($query){
        return redirect()->route('Oeuvre')->with('success','updated successfuly');

        }
    }

MY edit.blade.php

<form  action="{{ route('Oeuvre.update',$oeuvre) }}" enctype="multipart/form-data" method="POST">
@csrf
@method('PUT')
<div >
    <div >
        <div >
            <input  value="{{$oeuvre->titre}}" name="titre" type="text" placeholder="titre" />
            
            <label for="titre">Titre</label>
        </div>
    </div>
    <div >
        <div >
            <input  value="{{$oeuvre->auteur}}" name="auteur" type="text" placeholder="auteur" />
            <label for="auteur">Auteur</label>
        </div>
    </div>

CodePudding user response:

You need to change your form to be like this <form action="{{ route('Oeuvre.update',['oeuvre' => $oeuvre->id]) }}" enctype="multipart/form-data" method="POST">

CodePudding user response:

I think what is happening is that you are using this parameter in your controller => $oeuvre

Then you have to pass it also through your form and route

  • Related