Answer the question
In order to leave comments, you need to log in
Database queries. LARAVEL?
Perhaps this will be the most stupid question on this site. But yo-mayo.. I can't query the database via DB::table. PHPStorm tells me that this method does not exist... Okay, let's ignore it. I go to the browser, and then I get:
use Illuminate\Support\Facades\DB;
...
$user = DB::table('users')->where('username', '=', Auth::user());
if ($user->username == NULL && $user->email == NULL) {
//тест
return redirect('/badlogin');
}
Answer the question
In order to leave comments, you need to log in
When will people start reading documentation?
First, what is where('username', '=', Auth::user())
Auth::user() it's an entire object, you're comparing it all against username instead of Auth::user()->username.
Secondly, get () has already been written, it is necessary to do it, but then it can issue an array of strings from the base. So use ->first().
And then the result is only after checking that the result exists at all, otherwise in case of any error you will have undefined property
if($user) {
}
php artisan make:auth
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question