Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Where clause does not work with config() data

Hello,

I have a environment variable NOTIFICATIONS_MAIL. I have a configuration file in which I retrieve the notifications mail.

'notifications' => [
	'email' => env('NOTIFICATIONS_MAIL'),
],

I retrieve the email in my controller : $email = config('nathan.notifications.email'). Then I find the user in the database.

$email = config('nathan.notifications.email');
$user = User::where('email', $email)->first();
$user->notify(new BackupDone());

$email contains the right email, but $user is null. I have even tried with a closure in the where clause, but it doesn't work either.

If I write the email directly in the variable $email = '[email protected]';, it works.

Why ?

Do you see anything wrong in my code ?

Thanks for your help.

V

0 likes
1 reply
vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

Well ... I had an error in the email address in the .env file. Probably very tired ;) ...

Please or to participate in this conversation.