當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Bundle::find方法代碼示例

本文整理匯總了PHP中Bundle::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Bundle::find方法的具體用法?PHP Bundle::find怎麽用?PHP Bundle::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bundle的用法示例。


在下文中一共展示了Bundle::find方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete_album

 public function delete_album($id)
 {
     $bundle = Bundle::find($id);
     if (!is_null($bundle)) {
         if ($bundle->artist != Auth::user()->id) {
             return Redirect::to('/');
         } else {
             $bundle->delete();
             return Redirect::to('/artist/' . Auth::user()->profile_url);
         }
     }
 }
開發者ID:centaurustech,項目名稱:musicequity,代碼行數:12,代碼來源:ArtistsController.php

示例2: checkout

 public function checkout()
 {
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $items = [];
     $session = Session::get('cart.songs');
     $bundles = Session::get('cart.bundles');
     $total = 0;
     if (count($session) == 0 && count($bundles) == 0) {
         die('No Items in you cart');
     }
     $songs_string = "";
     $bundles_string = "";
     if (count($session) != 0) {
         foreach ($session as $s) {
             $song = Song::find($s['id']);
             $item = new Item();
             $item->setName($song->title)->setCurrency('AUD')->setQuantity(1)->setPrice($song->price);
             $items[] = $item;
             $total += $song->price;
             $songs_string .= "," . $song->id;
         }
     }
     if (count($bundles) != 0) {
         foreach ($bundles as $s) {
             $bundles = Bundle::find($s['id']);
             $item = new Item();
             $item->setName($bundles->name)->setCurrency('AUD')->setQuantity(1)->setPrice($bundles->price);
             $items[] = $item;
             $total += $bundles->price;
             $bundles_string .= "," . $bundles->id;
         }
     }
     $item_list = new ItemList();
     $item_list->setItems($items);
     $amount = new Amount();
     $amount->setCurrency('AUD')->setTotal($total);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Music Equity Song Purchase');
     $redirect_urls = new RedirectUrls();
     $redirect_urls->setReturnUrl(URL::route('payment.status'))->setCancelUrl(URL::route('payment.status'));
     $payment = new Payment();
     $payment->setIntent('Sale')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction));
     try {
         $payment->create($this->_api_context);
     } catch (\PayPal\Exception\PPConnectionException $ex) {
         if (\Config::get('app.debug')) {
             echo "Exception: " . $ex->getMessage() . PHP_EOL;
             $err_data = json_decode($ex->getData(), true);
             exit;
         } else {
             die('Some error occur, sorry for inconvenient');
         }
     }
     foreach ($payment->getLinks() as $link) {
         if ($link->getRel() == 'approval_url') {
             $redirect_url = $link->getHref();
             break;
         }
     }
     $t = new MyTransaction();
     $t->amount = $total;
     if (Auth::check()) {
         $t->customer = Auth::user()->id;
     } else {
         $t->customer = '0';
     }
     $t->songs = $songs_string;
     $t->bundles = $bundles_string;
     $t->status = 'OPEN';
     $t->paypal_id = $payment->getId();
     $t->save();
     // add payment ID to session
     Session::put('paypal_payment_id', $payment->getId());
     if (isset($redirect_url)) {
         // redirect to paypal
         return Redirect::away($redirect_url);
     }
 }
開發者ID:centaurustech,項目名稱:musicequity,代碼行數:79,代碼來源:PayPalController.php

示例3: add_bundle_to_cart

 public function add_bundle_to_cart($bundle)
 {
     $bundle = Bundle::find($bundle);
     if (!is_null($bundle)) {
         $data = ['id' => $bundle->id, 'title' => $bundle->name, 'price' => $bundle->price];
         Session::push('cart.bundles', $data);
         return Response::json(['id' => $bundle->id, 'price' => $bundle->price]);
     } else {
         App::abort('404');
     }
 }
開發者ID:centaurustech,項目名稱:musicequity,代碼行數:11,代碼來源:CustomerController.php


注:本文中的Bundle::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。