Working on a project I got stuck on the following thing. When I run the seeder in ssh it works perfectly but when I'm doing a call on the same model User inside a controller, the following error appears:
Illuminate\Database\QueryException: could not find driver
It doens't make sense that the seeder works perfectly but by a controller it doesn't.
Controller call:
$user = User::where('email', $mail)->firstOrFail()
Seeder call:
$user = User::create([
'name' => 'foo',
'email' => '[email protected]'
]);
I already checked the following:
What else could it be?
The problem was, the driver was enabled but without any driver. After Ubuntu 14.xx you need to define the actual php version instead of installing without a version number.
sudo apt-get install php8.0-mysql
In my situation I use the above command and it fixed my issue.