/** * Created By Dara on 28/12/2015 * addon management admin control */ public function adminIndex(User $user) { $addons = Addon::latest()->lists('name')->toArray(); //get all addon names $validAddon = []; foreach ($addons as $addon) { $validAddon[] = "App\\" . ucfirst($addon); //create the itemable_type (APP\Shop ....) } $payments = $user->payments()->where('status', '=', 1)->whereIn('itemable_type', $validAddon)->groupBy('itemable_type')->get(); return view('admin.addon.index', compact('user', 'payments'))->with(['title' => 'User Addon Management']); }