本文整理匯總了PHP中app\Book::select方法的典型用法代碼示例。如果您正苦於以下問題:PHP Book::select方法的具體用法?PHP Book::select怎麽用?PHP Book::select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Book
的用法示例。
在下文中一共展示了Book::select方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
public function index()
{
$slidebook = Book::join('genre', 'genre.id', '=', 'book.genre_id')->join('author', 'author.id', '=', 'book.author_id')->join('publisher', 'publisher.id', '=', 'book.publisher_id')->select('book.id', 'title', 'genre_id', 'genre.name as genre_name', 'author_id', 'author.name as author_name', 'publisher_id', 'publisher.name as publisher_name', 'image', 'isbn', 'price', 'sale')->where('book.deleted', '=', 0)->where('quantity', '>', 0)->orderBy('created_at', 'desc')->take(5)->get();
$newbooks = Book::select('id', 'title', 'image', 'price', 'sale')->where('book.deleted', '=', 0)->where('quantity', '>', 0)->orderBy('created_at', 'desc')->take(8)->get();
$salebooks = Book::select('id', 'title', 'image', 'price', 'sale')->where('book.deleted', '=', 0)->where('quantity', '>', 0)->where('sale', '>', 0)->take(8)->get();
$book_data = array('slidebook' => $slidebook, 'newbook' => $newbooks, 'salebook' => $salebooks);
return view('pages.index')->with('book_data', $book_data);
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($slug)
{
$imagePath = \Config::get('library.uploads.webpath');
$imageCoverName = \Config::get('library.uploads.cover_name');
$deffaultImage = \Config::get('library.uploads.deffault_image');
$book = Book::select('id', 'title', 'description', 'pages', 'isdn', 'published_at', 'category_id', 'format_id')->with(array('authors', 'category', 'format'))->where('slug', 'like', $slug)->firstOrFail();
return view('user.viewBook', compact('book', 'imagePath', 'imageCoverName', 'deffaultImage'));
}
示例3: postPayment
public function postPayment()
{
$data = Input::get('option');
foreach ($data as $key => $value) {
$id_books[] = $key;
$article[$key] = array('option' => $value[0], 'days' => $value['day'], 'id' => $key);
}
$books = Book::select('id', 'title', 'price_day', 'price_bail', 'price_sale')->find($id_books);
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$items = array();
$subtotal = 0;
$currency = 'EUR';
foreach ($books as $producto) {
if ($article[$producto->id]['option'] == 'rent' && $article[$producto->id]['days'] > 0) {
$price = $producto->price_day * $article[$producto->id]['days'] + $producto->price_bail;
} else {
$price = $producto->price_sale;
}
$item = new Item();
$item->setName($producto->title)->setCurrency($currency)->setDescription($producto->title)->setQuantity(1)->setPrice($price)->setSku($producto->id);
$items[] = $item;
$subtotal += $price;
}
$item_list = new ItemList();
$item_list->setItems($items);
$details = new Details();
$details->setSubtotal($subtotal)->setShipping(0);
$amount = new Amount();
$amount->setCurrency($currency)->setTotal($subtotal)->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($item_list)->setDescription('Pedido de prueba en mi Laravel App Store');
$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('Ups! Algo salió mal');
}
}
foreach ($payment->getLinks() as $link) {
if ($link->getRel() == 'approval_url') {
$redirect_url = $link->getHref();
break;
}
}
// add payment ID to session
Session::put('paypal_payment_id', $payment->getId());
Session::put('articles', $article);
if (isset($redirect_url)) {
// redirect to paypal
return Redirect::away($redirect_url);
}
return Redirect::route('cart-show')->with('error', 'Ups! Error desconocido.');
}