vendredi 3 juillet 2020

where condition with laravel has many relationship

I am trying to get record with where condition in laravel elquent query. Here is my relationship method.

      public function OrdersReferrals(){
            return $this->hasMany('App\Order','referred_by');
        }

public function referrals()
{
    return $this->hasMany('App\User','referred_by')->with('referrals','OrdersReferrals');
}

Here Is My  controller Query
   $userData=User::with('adminuserrreferrals')->where('id',$id)->where('payout_status','pending')->get();

Problem Is that this query, Where condition is work for only user table. while I need this ->where('payout_status','pending') for Orders Table .

Let me know if any possible solution PLease



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire