qsadfasdgfgads

Untitled

Feb 12th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. public function show($id)
  2.     {
  3.         $card = Card::getByParcedId($id);
  4.  
  5.         $validations = collect();
  6.  
  7.         $categories = Category::all();
  8.         $discounts = collect();
  9.         if ($card->hasActiveSubscription()) {
  10.             $cs_id = $card->activeSubscription()->pivot->id;
  11.             if (auth()->check() && auth()->user()->hasAnyRole(['shopuser', 'shopadmin'])) {
  12.                 $validations = DiscountUse::where('is_validated', false)->where('validation_sent', '>', Carbon::parse('-5 minutes'))->where('card_subscription_id', $cs_id)->get();
  13.             }
  14.  
  15.             $discounts = collect();
  16.  
  17.             if (!request()->input('category') || request()->input('category') == 'all') {
  18.                 $discounts = $card->activeSubscription()->discounts()->byCity()->paginate(15)->appends('category');
  19.  
  20.             } else {
  21.                 $cat = request()->input('category');
  22.                 $discounts = $card->activeSubscription()->discounts()
  23.                     ->whereHas('shop', function ($q) use ($cat) {
  24.                         $q->where('category_id', $cat);
  25.  
  26.                     })->byCity()
  27.                     ->paginate(20);
  28.  
  29.             }
  30.         }
  31.  
  32.  
  33.         return view('v2.cards.show')
  34.             ->with('card', $card)
  35.             ->with('validation', $validations)
  36.             ->with('discounts', $discounts)
  37.             ->with('categories', $categories);
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment