Good morning ...
I have tried to translate this query but it does not work for me in eloquen
select * from usuarios where usuario_ad='danielad' and user_id;
I must be making a small mistake
Good morning ...
I have tried to translate this query but it does not work for me in eloquen
select * from usuarios where usuario_ad='danielad' and user_id;
I must be making a small mistake
Query in pure SQL, is incomplete because you need to match the user_id
with something; for example put like this:
user_id = 1
With the above, the sentence would be complete; now passing it first to Laravel query builder Fluent would stay like this:
$data = \DB::table('usuarios')
->where('usuario_ad', 'danielad')
->where('user_id', 2)
->get();
That is, in the previous code, equal the user_id
with 2 as a mere example
Now that same consultation with Eloquent
$data = User::where('usuario_ad', 'danielad')
->where('user_id', 2)
->get();
I simply put the Facade \DB
with the name of the model, which in this case I put User
but it should have if you have it that you have declared
On the other hand as a final point, to achieve this
where(.....) AND(.......)
In Laravel you just have to link, for example, the access to two methods where
in this way
where()
->where()