0

I am trying to handle a basic form with laravel and am running in to an issue where my POST route isn't being detected and is resulting in a route not defined error in the blade template. My goal is to resolve this error and post the form to the controller, then access the various form fields with the $request param.

error: Route [withdraw.update] not defined.

WithdrawController.php

public function update_withdraw(Request $request, $id)
    {
        $withdraw = Withdraw::findOrFail($id);

        $withdraw->status = $request->input('status');
            if ($request->hasFile('dekont')) {
            $file = $request->file('dekont');
            $filename = time() . '.' . $file->getClientOriginalExtension();
            $file->move(public_path('dekont'), $filename);
            $withdraw->dekont = $filename;
    }

        $withdraw->save();

        return redirect()->back()->with('success', 'Withdraw request has been updated successfully.');
    } 
Route::put('withdraw/update/{id}', 'WithdrawController@update_withdraw')->name('withdraw.update');

onay.blade.php

 <form method="post" action="{{ route('withdraw.update', $withdraw->id) }}">
                    @csrf
                    @method('PUT')
                    <div class="form-group row">
                        <label for="status" class="col-sm-3 col-form-label">{{ __('Status') }}</label>
                        <div class="col-sm-9">
                            <select name="status" id="status" class="form-control" required>
                                <option value="1" {{ $withdraw->status == 1 ? 'selected' : '' }}>{{ __('Approved') }}</option>
                                <option value="0" {{ $withdraw->status == 0 ? 'selected' : '' }}>{{ __('Rejected') }}</option>
                                <option value="2" {{ $withdraw->status == 2 ? 'selected' : '' }}>{{ __('Pending') }}</option>
                            </select>
                            <label for="dekont">Dekont Yükle</label>
                            <input type="file" name="dekont" id="dekont">
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-sm-9 offset-sm-3">
                            <button type="submit" class="btn btn-primary">{{ __('Update') }}</button>
                        </div>
                    </div>
                </form> 
erme saral
  • 29
  • 3

1 Answers1

0

[WithdrawController::class, 'update'] fixed with this

erme saral
  • 29
  • 3