whereHas('user', function($query){ $query->where('id', '>', 1)->whereHas('role', function($q){ $q->where(function($q) { $q->where('type', 'admin')->orWhere('type', 'staff'); })->whereHas('permissions', function($q) { $q->where('route', 'mlm-downline.index'); }); }); })->latest()->get(); } public function assignUpline($downline, $upline_id) { $downline->parent_id = $upline_id; $downline->update(); } }