本文整理汇总了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);
}
}
}
示例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);
}
}
示例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');
}
}