本文整理汇总了PHP中Album::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::find方法的具体用法?PHP Album::find怎么用?PHP Album::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showAlbum
public function showAlbum($id)
{
$album = Album::find($id);
//Album::find(array(1, 3));
//Album::first();
return $album;
}
示例2: eventBeforeDelete
public function eventBeforeDelete($event)
{
$items = Album::find()->where(['cat_id' => $this->id])->all();
if (count($items) > 0) {
$this->addError('Diese Kategorie wird noch von einem oder mehreren Alben benutzt und kann nicht gelöscht werden.');
$event->isValid = false;
return;
}
$event->isValid = true;
}
示例3: __construct
/**
* These methods are handled by the BaseUploadHandler
*
* public function Start();
* public function get_response();
* public function get_headers();
* public function set_option(string $key, string $value);
*/
function __construct($options, $arguments = null)
{
$folder = $arguments;
if (!$folder instanceof \Album and (!is_numeric($arguments) or !($folder = \Album::find($arguments)))) {
throw new \Exception("DatabaseUploadHandler needs the Album id or the Album model to start!");
}
$this->folder = $folder;
$options['upload_dir'] = $folder->upload_dir;
$options['upload_url'] = $folder->upload_url;
parent::__construct($options);
}
示例4: postAlbumComment
public function postAlbumComment($id)
{
$album = Album::find($id);
if ($album === null) {
$error = 'Can not post comment. No such album found.';
return View::make('errors.error', array('errorMsg' => $error));
}
$input = Input::all();
$comment = new Comment(['content' => $input['content'], 'author_id' => Auth::user()->id, 'album_id' => $id]);
$comment->save();
return Redirect::to('/albums/' . $id);
}
示例5: delete
public function delete($id)
{
$album = Album::find($id);
if ($album === null) {
$error = 'Invalid album.';
return View::make('errors.error', array('errorMsg' => $error));
}
if ($album->owner_id !== Auth::user()->id) {
$error = 'You don\'t have permission to delete this album. You are not it\'s owner.';
return View::make('errors.error', array('errorMsg' => $error));
}
//delete all photos
Photo::where('album_id', '=', $album->id)->delete();
//delete album
$album->delete();
return Redirect::to('/albums/own');
}
示例6: vote
public function vote($id)
{
$album = Album::find($id);
if ($album === null) {
$error = 'Can not vote. No such album found.';
return View::make('errors.error', array('errorMsg' => $error));
}
$input = Input::all();
if (1 > $input['vote'] || $input['vote'] > 10) {
$error = 'Invalid vote. Must be between 1 and 10.';
return View::make('errors.error', array('errorMsg' => $error));
}
$vote = new Vote(['value' => $input['vote'], 'album_id' => $album->id, 'voter_id' => Auth::user()->id]);
$album->rank = $album->rank + $vote->value;
$album->save();
$vote->save();
return Redirect::to('/albums/' . $album->id);
}
示例7: save
public static function save($data, $id = null)
{
if ($id == null) {
$album = new Album();
$album->category_id = $data['category_id'];
$album->user_id = Session::get('current_user');
$album->public = $data['public'];
$album->title = $data['title'];
$album->description = $data['description'];
$album->is_single = $data['is_single'];
$album->post_id = $data['post_id'];
$album->count_like = 0;
} else {
$album = Album::find($id);
$album->title = $data['title'];
$album->description = isset($data['description']) ? $data['description'] : "";
$album->category_id = $data['category_id'];
}
if ($album->save()) {
return $album;
}
}
示例8: picture
public function picture()
{
$album_id = Input::get('album_id');
$album = Album::find($album_id);
if ($album == null) {
return Response::json(array('errCode' => 1, 'message' => '此相册不存在!', 'pictures' => ''));
}
$pictures = $album->hasManyPictures()->get();
if (count($pictures) != 0) {
return Response::json(array('errCode' => 0, 'message' => '返回相片', 'pictures' => $pictures));
}
return Response::json(array('errCode' => 1, 'message' => '该相册没有图片', 'pictures' => ''));
}
示例9: detail_gallery
public function detail_gallery($id)
{
$album = Album::find($id);
$detail = DB::table('detail_album')->where('id_album', '=', $id)->get();
return View::make('web.detailalbum')->with('album', $album)->with('detail', $detail);
}
示例10: getGallery
/**
* Get model gallery
* @param Model $Model
* @return mixed
*/
public function getGallery(Model $Model)
{
$Album = new Album();
return $Album->find('first', array('conditions' => array('model' => $Model->alias, 'model_id' => $Model->id)));
}
示例11: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$album = Album::find($id);
if (empty($album)) {
return App::abort('404');
}
if (!$album->deleteAlbum()) {
Session::flash('flash_error', trans('message.album.error.delete_failed'));
} else {
Session::flash('flash_success', trans('message.album.success.delete_ok'));
}
return Redirect::route('secured.album.index');
}
示例12: getThumburlAttribute
public function getThumburlAttribute()
{
$album = Album::find($this->album_id);
return Config::get('filegallery.imagesfolder') . '/' . $album->folder . '/thumbs/' . $this->image;
}
示例13: saveSong
public function saveSong($id)
{
$validator = Validator::make(Input::all(), array('song_title' => 'required', 'video_code' => 'required'));
if ($validator->fails()) {
return Redirect::route('edit-albums')->withInput()->withErrors($validator)->with('song_modal', '#song_modal')->with('album-id', $id);
} else {
$album = Album::find($id);
if ($album == null) {
return Redirect::route('edit-albums')->with('fail', "That album doesn't exist.");
}
$song = new Song();
$song->title = Input::get('song_title');
$song->video = Input::get('video_code');
$song->album_id = $id;
if ($song->save()) {
return Redirect::route('edit-albums')->with('success', 'The song was added.');
} else {
return Redirect::route('edit-albums')->with('fail', 'An error occured while saving the new song.');
}
}
}
示例14: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
$album = Album::find($id);
$album->getEntry()->delete();
foreach ($album->images as $image) {
$image->delete();
}
$album->delete();
Session::flash('status', true);
Session::flash('messages', array('Đã xóa ảnh'));
return Redirect::route('admin.album.index');
}
示例15: intval
<?php
include 'models.php';
if (isset($_POST['id'])) {
$a = Album::find($_POST['id']);
$a->Title = $_POST['title'];
$a->Artist = intval($_POST['artist']);
if ($a->save()) {
header("Location: " . "album.php?id=" . $a->AlbumId);
}
} else {
$a = Album::create($_POST['title'], intval($_POST['artist']));
if ($a->save()) {
header("Location: " . "album.php?id=" . $a->AlbumId);
}
}