the browser-facing portion of osu!
at master 973 B view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Http\Controllers\Store; 7 8use App\Http\Controllers\Controller as BaseController; 9use App\Models\Store\Order; 10use Auth; 11 12abstract class Controller extends BaseController 13{ 14 public function __construct() 15 { 16 parent::__construct(); 17 } 18 19 /** 20 * Gets the cart of the currently logged in user. 21 * 22 * TODO: should probably memoize this 23 * 24 * @return Order|null cart of the current user if logged in; null, if not logged in. 25 */ 26 protected function userCart() 27 { 28 if (Auth::check()) { 29 return Order::cart(Auth::user()) ?? new Order(['user_id' => Auth::user()->user_id]); 30 } 31 } 32 33 protected function isAllowRestrictedUsers() 34 { 35 return $GLOBALS['cfg']['store']['allow_restricted_users']; 36 } 37}