Missing required parameters for [Route: listajoburi.update] [URI: listajoburiupdate{id}].

Posted 3 months ago by PaulCatalin97

i`m new to laravel, why do i get this error ? i have passed the parameters.

this is the blade file

 <form action="{{route('listajoburi.update', $id)}}" method="post" enctype="multipart/form-data">
                @csrf
                <div class="box-body">
                    <div class="form-group">
                        <label for="exampleInputEmail1">Nume Job</label>
                        <input type="text" class="form-control" id="titlu" name="titlu" value="{{$joburi->titlu}}"/>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">Descriere:</label>
                        <input type="text" class="form-control" id="descriere" name="descriere" value="{{$joburi->descriere}}"/>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">Salariu Estimativ:</label>
                        <input type="text" class="form-control" id="salariu_estimativ" name="salariu_estimativ" value="{{$joburi->salariu_estimativ}}"/>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">Oras:</label>
                        <input type="text" class="form-control" id="oras" name="oras" value="{{$joburi->oras}}"/>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">Activ(1=activ,0=inactiv)</label>
                        <input type="text" class="form-control" id="activ" name="ativ" value="{{$joburi->activ}}">
                    </div>

this is the controller

public function index()
    {
        $joburi = Joburi::all()->toArray();
        return view('listajoburi', compact('joburi'));
    }

    public function edit($id)
    {
        $joburi = Joburi::find($id);
        return view('editarejob', compact('joburi', 'id'));
    }

    public function update(Request $request, $id)
    {
        $this->validator($request->all());

        $update = Joburi::find($id)->update([
            'titlu' => $request->titlu,
            'descriere' => $request->descriere,
            'salariu_estimativ' => $request->salariu_estimativ,
            'oras' => $request->oras,
            'activ' => $request->activ,
            //  'skill' => $request->city,
        ]);

        if ($update) {
            return redirect()->route('listajoburi.update')->withSuccess('S-a modificat cu success!');
        } else {
            return redirect()->back()->withDanger('Nu s-a modificat! A aparut o eroare.');
        }
    }

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'titlu' => ['required', 'string', 'min:3', 'max:255'],
            'descriere' => ['required', 'string', 'max:11'],
            'salariu_estimativ' => ['required', ''],
            'oras' => ['string', 'max:512'],
            'activ' => ['required', 'string', 'max:512'],
            // 'skill' => ['string', 'max:45'],
        ]);

    }
}

and this is the route

Route::get('/listajoburi', 'Auth\[email protected]')->name('listajoburi');
Route::get('/editarejob/{id}/', 'Auth\[email protected]')->name('editarejob');
Route::post('/listajoburiupdate/{id}', 'Auth\[email protected]')->name('listajoburi.update');

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