O
O
Ohjovanni2019-04-28 19:35:50
Laravel
Ohjovanni, 2019-04-28 19:35:50

Why does eloquent swear?

I'm trying to display matches like this:
(I use orm separately from Laravel, because the task is like this)

public function myMethod()
    {
        $user = new Users();
        $user->whereHas('users',function ($q)
        {
              $q->where('name','admin');
        })->get();
    }

I get this:
Fatal error: Uncaught BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::users() in

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2019-04-28
@Ohjovanni

$user = new Users()->where('name','admin')->get();
apparently you wanted to do it, from somewhere you just got whereHas and for some reason shoved it here.
the use of the laravel docks in which eloquent is described does not cancel this, everything is painted there subroutinely.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question