本文整理汇总了PHP中Song::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::find方法的具体用法?PHP Song::find怎么用?PHP Song::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Song
的用法示例。
在下文中一共展示了Song::find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show the form for editing the specified song.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$song = Song::find($id);
return View::make('songs.edit', compact('song'));
}
示例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: addSample
public function addSample($songID)
{
$song = Song::find($songID);
if ($song == null) {
return Redirect::route('albums-home')->with('fail', "That song doesn't exist.");
}
if (Input::get('sample-artist') == '') {
return Redirect::route('albums-home')->with('fail', "Please enter Artist Name.");
}
if (Input::get('sample-title') == '') {
return Redirect::route('albums-home')->with('fail', "Please enter Song Title.");
}
$sample = new Sample();
$sample->song_id = $songID;
$sample->sample_artist = Input::get('sample-artist');
$sample->sample_title = Input::get('sample-title');
$sample->author_id = Auth::user()->id;
$action = new Action();
$action->song_title = $song->title;
$action->action = "Added sample";
$action->user_id = Auth::user()->id;
if ($sample->save() && $action->save()) {
return Redirect::route('albums-home')->with('success', 'The sample was added.');
} else {
return Redirect::route('albums-home')->with('fail', 'An error occured while saving the sample.');
}
}
示例4: addsong
/**
* Handle song initialisation submit form
*/
public function addsong()
{
$input = Input::all();
$song_id = $input['song'];
$song = Song::find($song_id);
if ($song->artist != Auth::user()->id) {
return Redirect::to('/');
} else {
if (Input::has('art_cropped')) {
$image = Input::get('art_cropped');
$exp = explode(",", $image);
$data = base64_decode($exp[1]);
$name = str_random(15);
$tempfile = storage_path() . "/temp/" . $name . "";
file_put_contents($tempfile, $data);
$image_info = getImageSize($tempfile);
switch ($image_info['mime']) {
case 'image/gif':
$extension = '.gif';
break;
case 'image/jpeg':
$extension = '.jpg';
break;
case 'image/png':
$extension = '.png';
break;
default:
// handle errors
break;
}
// open file a image resource
$img = Image::make($tempfile);
$img->save($tempfile);
$large = Image::make($tempfile)->resize(120, 120)->save($song->path . "/" . $song->sample . "-large" . $extension);
$small = Image::make($tempfile)->resize(50, 50)->save($song->path . "/" . $song->sample . "-small" . $extension);
$song->art = $song->path . "/" . $song->sample . "-large" . $extension;
unlink($tempfile);
}
$song->genre = $input['genre'];
$song->title = $input['title'];
$song->price = $input['price'];
$song->description = $input['description'];
$song->completed = true;
if (Input::has('charity')) {
if (Input::get('charity_share') > 0) {
if (is_numeric(Input::get('charity_share'))) {
$charity = Charity::find($input['charity']);
if ($charity) {
$song->charity_share = $input['charity_share'];
$song->charity = $input['charity'];
}
}
}
}
$song->save();
Session::forget('song');
}
return Redirect::to('/artist/' . Auth::user()->profile_url);
}
示例5: decline
public function decline($id)
{
$song = Song::find($id);
$me = Auth::user();
if (count($song) < 1 || $song->charity != $me->charity->id) {
return false;
}
$song->charity = '';
$song->save();
return Redirect::to('charity/' . $me->profile_url);
}
示例6: postVote
function postVote($songId)
{
$vote = Input::get('vote');
$song = Song::find($songId);
$song->voted = true;
if ($vote == 'YES') {
$song->status = 'ingestemd';
} else {
$song->status = 'uitgestemd';
}
$song->save();
return Response::json(true);
}
示例7: add_to_cart
/**
* Add song to a cart
*
* @param $song
* @return Response
*/
public function add_to_cart($song)
{
$song = Song::find($song);
if (!is_null($song)) {
$song_title = preg_replace('%[^A-Za-z0-9 ]%', '', $song->title);
$data = ['id' => $song->id, 'title' => $song_title, 'price' => $song->price];
Session::push('cart.songs', $data);
return Response::json(['id' => $song->id, 'price' => $song->price]);
} else {
App::abort('404');
}
}