Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function show($id)
- {
- $card = Card::getByParcedId($id);
- $validations = collect();
- $categories = Category::all();
- $discounts = collect();
- if ($card->hasActiveSubscription()) {
- $cs_id = $card->activeSubscription()->pivot->id;
- if (auth()->check() && auth()->user()->hasAnyRole(['shopuser', 'shopadmin'])) {
- $validations = DiscountUse::where('is_validated', false)->where('validation_sent', '>', Carbon::parse('-5 minutes'))->where('card_subscription_id', $cs_id)->get();
- }
- $discounts = collect();
- if (!request()->input('category') || request()->input('category') == 'all') {
- $discounts = $card->activeSubscription()->discounts()->byCity()->paginate(15)->appends('category');
- } else {
- $cat = request()->input('category');
- $discounts = $card->activeSubscription()->discounts()
- ->whereHas('shop', function ($q) use ($cat) {
- $q->where('category_id', $cat);
- })->byCity()
- ->paginate(20);
- }
- }
- return view('v2.cards.show')
- ->with('card', $card)
- ->with('validation', $validations)
- ->with('discounts', $discounts)
- ->with('categories', $categories);
- }
Advertisement
Add Comment
Please, Sign In to add comment