Ad

Laravel: REJECT ROUTE Not Defined But Exists In Web.php

I have a reject function in my Calendar controller but whenever I redirect to the view page it displays an error saying my route is not defined.

I've tried rearranging and renaming my route but it's still displaying the error.

Here is my form:

{!! Form::open(['url' => route('therapist.reject.appointment', $bookingRequest), 'method' => 'delete', 'onsubmit' => 'javascript:return confirm("Are you sure?")']) !!}
                                <button type="submit" class="btn btn-warning btn-block">Reject this appointment</button>
                                {{csrf_field()}}
                            {!! Form::close() !!}

Here are my routes. The other routes displayed are working perfectly:

Route::get('therapist-calendar/{bookingRequest}', 'TherapistCalander')->name('therapist.calendar');

    Route::post('therapist-calendar/{bookingRequest}',
        '[email protected]')->name('therapist.book.appointment');

    Route::patch('therapist-calendar/{bookingRequest}', 
        '[email protected]')->name('therapist.finish.appointment');

    Route::delete('therapist-calendar/{bookingRequest}',
    '[email protected]')->name('therapist.reject.appointment');

    Route::delete('therapist-calendar/{bookingRequest}', 
        '[email protected]')->name('therapist.cancel.appointment');

And lastly, my function:

public function rejectAppointment(Request $request, BookingRequest $bookingRequest)
    {
        $bookingRequest->reject();

        return redirect()->back()->with('rejectStatus', true);
    }

The view page where this button belongs should be able to display the buttons for rejecting and finishing, alongside the calendar view.

EDIT Follow up question: Is it possibly because the routes are similar to one another? If so, how do I fix this?

Ad

Answer

UPDATE

PROBLEM FIXED

I realized since they have similar links, web.php found it confusing so it did not read this route.

That is why I changed my route from:

  Route::delete('therapist-calendar/{bookingRequest}',
'[email protected]')->name('therapist.reject.appointment');

To this:

Route::delete('doReject/{bookingRequest}',
    '[email protected]')->name('therapist.reject.appointment');
Ad
source: stackoverflow.com
Ad