santino
1 month ago

HELP, I cant use orWhere

Posted 1 month ago by santino

Hi, I am trying to use orWhere in this code ,

    public function clientOrders()
    {
        return $this->hasManyThrough(
            'App\Order',
            'App\UserProvider',
            'user_id', // Foreign key on UserProvider table...
            'portfolio_id', // Foreign key on User table...
            'id', // Local key on Order table...
            'id', // Foreign key on UserProvider table...
        );
    }


    public function clientOrdersOnReview()
    {
        return $this->clientOrders()->where( 'signed' , 0 );
    }

this code is working fine but I want to do something like this

     return $this->clientOrders()->where( 'signed' , 0 )->orWhere( 'finished' , 0 );

But it RETURNs all the orders from all the users....

I am trying to recreate this same laravel code

		return user()->clientOrders()
		->where('signed', 0)
		->orWhere('finished', 0)
		->get();

this return all the orders...

BUT it weird because I can do this double where

		return user()->clientOrders()
		->where('signed', 1)->where('finished', 0)
		->get();

and actually the code runs perfectly and makes the query!!! thanks for any help or hint

Please sign in or create an account to participate in this conversation.