Reputation: 123
I'm trying to implement a new method in a BoController called "deleteBooking", the method is defined:
public function deleteBooking($id){
$booking = Reservation::find($id);
if($booking && $booking->delete()){
try {
$email = Mail::to($booking->user_email)->send(new Cancel($booking));
} catch(\Exception $e){
Log::error($e->getMessage());
}
return redirect('admin/manager/home')->with('message','Réservation annulée!');
}
return redirect('admin/manager/home')->with('message','Réservation non annulée!');
}
But laravel at the endpoint says:
(1/1) BadMethodCallException
Method [deleteBooking] does not exist.
Other methods from the same class are linked to endpoints too, and work well.
Do you have any ideas please? Thank you.
Upvotes: 1
Views: 6589
Reputation: 493
I have faced similar issue. Then I have figured out a issue pointed in composer install log, with following instance of log line:
Class App\Http\Controllers\BlogController located in ./app/Http/Controllers/BlogControllerOld.php does not comply with psr-4 autoloading standard. Skipping.
Based on that I have found that one of the file renamed with Old suffix was creating conflict with the main file. So here I have to chhoseone of the following solutions:
So its a good idea to check for issues with composer install
It will highlight the conflicts that can be fixed using one of the method above.
Once fixed using specified methods above issue composer install
to apply the fix and regenerate autoloader.
Upvotes: 0
Reputation: 123
I got it fixed, I've found another file called BoController, in another folder somehow and it was conflicting with the App\Http\Controllers one.
Thank you.
Upvotes: 1
Reputation: 1089
It's most likely that you have declared that function for some other request type other than the one you're trying to make. For example you put Route::post('some-method', 'BoController@deleteBooking');
but you need to put either Route::get(...)
or Route::put(...)
or Route::delete(...)
.
If it isn't that problem, then you probably misspelled it.
Upvotes: 0