SnapShooter Backups Server, Database, Application and Laravel Backups - Get fully protected with SnapShooter

How to Fix Bad Method Call Exception in Laravel

If you are seeing this exception in your Laravel application:

BadMethodCallException Method [find] does not exist

Firstly, you might want to check if you are accessing methods that do not exist in the object. If that is not the case, there are a few other possibilities.

You Are Calling a Different Class With The Same Name.

The class you are calling is not the same one you need, to check and validate, check the use statements at the beginning of the file. For example, if you want to use the User class from Eloquent, the use statement should be the one as shown below:

use Model\User;

Clear Composer Cache

Sometimes, there's is something wrong with autoloading, you can run the command below to refresh the composer's autoloading:

composer dumpautoload

Corrupted Laravel Vendor Code

It happens when you try to edit Laravel's core code base. In this case, you will want to re-download the Laravel Vendor Code.

Firstly, you delete the Laravel code:

rm -rf vendor/laravel

Then reinstall it again by running the command below:

composer update

The End

We have covered all the possible reasons for the BadMethodCall exception in Laravel. Hope you find it useful.