php - Page showing blank Laravel -
i have laravel project that's supposed person's referral 3 levels deep. here controller query.
public function matrix() { $referrals = db::table('users')->where('referred_by', auth::user()->referral_id)->get(); if (empty($referrals)) { return view('matrix'); } elseif(isset($referrals[0])) { $referrals2gen = db::table('users')->where('referred_by', $referrals[0]->referral_id)->get(); if (!isset($referrals2gen[0])) { $referrals3gen = db::table('users')->where('referred_by', $referrals2gen[0]->referral_id)->get(); if (!isset($referrals3gen[0])) { return view('matrix3', ['referrals' => $referrals, 'referrals2gen' => $referrals2gen]); } elseif(isset($referrals3gen[0])) { return view('matrix4', ['referrals' => $referrals, 'referrals2gen' => $referrals2gen, 'referrals3gen' => $referrals3gen]); } } } }
if user has referrals returns normal view. if doesnt retruns blank page. appreciate whatsover. note: know not dry beginner , have been having issues these while
why querying in controller.. best way solve problem easier create repository , leave controller clean. , query better use eloquent simple
here link
https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5/
wiki
Comments
Post a Comment