Esempio n. 1
0
function ujs_redirect($url)
{
    if (Request::ajax()) {
        return js_view('layout.ujs-redirect', ['url' => $url]);
    } else {
        return redirect($url);
    }
}
Esempio n. 2
0
function ujs_redirect($url)
{
    if (Request::ajax()) {
        return js_view("layout.ujs-redirect", ["url" => $url]);
    } else {
        return redirect($url);
    }
}
Esempio n. 3
0
 public function setLocale()
 {
     $newLocale = get_valid_locale(Request::input('locale'));
     App::setLocale($newLocale);
     if (Auth::check()) {
         Auth::user()->update(['user_lang' => $newLocale]);
     }
     return js_view('layout.ujs-reload')->withCookie(cookie()->forever('locale', $newLocale));
 }
Esempio n. 4
0
 public function postCheckout()
 {
     $order = $this->userCart();
     if (!$order) {
         return response(["message" => "cart is empty"], 422);
     }
     $order->refreshCost(true);
     if ($order->getTotal() == 0 && Request::input("completed")) {
         file_get_contents("https://osu.ppy.sh/web/ipn.php?mc_gross=0&item_number=store-{$order->user_id}-{$order->order_id}");
         return ujs_redirect(action("StoreController@getInvoice", [$order->order_id]) . "?thanks=1");
     }
     return js_view("store.order-create");
 }
 public function promote()
 {
     priv_check('LivestreamPromote')->ensureCan();
     LivestreamCollection::promote(Request::input('id'));
     return js_view('layout.ujs-reload');
 }
Esempio n. 6
0
 public function watch($id)
 {
     $topic = Topic::findOrFail($id);
     $state = get_bool(Request::input('watch'));
     $privName = 'ForumTopicWatch' . ($state ? 'Add' : 'Remove');
     $type = 'watch';
     priv_check($privName, $topic)->ensureCan();
     TopicWatch::toggle($topic, Auth::user(), $state);
     switch (Request::input('page')) {
         case 'manage':
             $topics = Topic::watchedByUser(Auth::user())->get();
             $topicReadStatus = TopicTrack::readStatus(Auth::user(), $topics);
             // there's currently only destroy action from watch index
             return js_view('forum.topic_watches.destroy', compact('topic', 'topics', 'topicReadStatus'));
         default:
             return js_view('forum.topics.replace_button', compact('topic', 'type', 'state'));
     }
 }
Esempio n. 7
0
 public function postCheckout()
 {
     $order = $this->userCart();
     if (!$order) {
         return response(['message' => 'cart is empty'], 422);
     }
     $order->refreshCost(true);
     if ((double) $order->getTotal() === 0.0 && Request::input('completed')) {
         file_get_contents("https://osu.ppy.sh/web/ipn.php?mc_gross=0&item_number=store-{$order->user_id}-{$order->order_id}");
         return ujs_redirect(action('StoreController@getInvoice', [$order->order_id]) . '?thanks=1');
     }
     return js_view('store.order-create');
 }
Esempio n. 8
0
 public function putRequestNotification($product_id, $action)
 {
     $user = Auth::user();
     $product = Store\Product::findOrFail($product_id);
     if ($product->inStock()) {
         return error_popup(trans('store.product.notification_in_stock'));
     }
     $request = $product->notificationRequests()->where('user_id', $user->user_id)->first();
     if ($request && $action === 'create') {
         return error_popup(trans('store.product.notification_exists'));
     } elseif ($request) {
         $request->delete();
     }
     if (!$request && $action === 'delete') {
         return error_popup(trans('store.product.notification_doesnt_exist'));
     } elseif (!$request) {
         $request = Store\NotificationRequest::create(['user_id' => $user->user_id, 'product_id' => $product_id]);
     }
     return js_view('layout.ujs-reload');
 }