public function showAlbum($id) { $album = Album::find($id); //Album::find(array(1, 3)); //Album::first(); return $album; }
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; }
/** * 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); }
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); }
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'); }
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); }
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; } }
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' => '')); }
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); }
/** * 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))); }
/** * 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'); }
public function getThumburlAttribute() { $album = Album::find($this->album_id); return Config::get('filegallery.imagesfolder') . '/' . $album->folder . '/thumbs/' . $this->image; }
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.'); } } }
/** * 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'); }
<?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); } }
public function edit($id) { $album = Album::find($id); return View::make('frontend/albums/edit')->with('album', $album); }
public function scanImg() { if (!Auth::check()) { return Response::json(array('errCode' => 1, 'message' => '请登录')); } $album_id = Input::get('album_id'); $pictures = Album::find($album_id); if (count($pictures) != 0) { return Response::json(array('errCode' => 0, 'message' => '返回图片', 'pictures' => $pictures)); } return Response::json(array('errCode' => 2, 'message' => '该相册不存在!')); }
public function api_get_album_by_id($album_id) { $album = Album::find($album_id); $data = array('id' => $album_id, 'name' => $album->name, 'artist_name' => $album->artist->name); return Response::json($data); }
public function update($id) { $album = Album::find($id); if (FEUsersHelper::isCurrentUser($album->id)) { $album->title = Input::get('title'); $album->privacy = Input::get('privacy'); $album->save(); FEEntriesHelper::updatePrivacy($album->id, 2, Input::get('privacy')); } return Redirect::back(); }
<?php include 'models.php'; if (isset($_GET['id'])) { $a = Album::find($_GET['id']); if ($a->delete()) { header("Location: index.php"); } } else { header("Location: index.php"); }
<!DOCTYPE html> <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> </script> <?php include 'models.php'; $album = isset($_GET['id']) ? Album::find($_GET['id']) : Album::create(null, 1); ?> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous"> <title>New Album</title> </head> <body> <div class="container"> <div class="jumbotron"> <h1>Nuevo Album</h1> <p></p> </div> <div class="row"> <div class="col-md-3 col-md-offset-4 col-xs-5 col-xs-offset-2 col-sm-4 col-sm-offset-4 "> <form action="guardar_album.php" method="POST"> <?php if (isset($album->AlbumId)) { ?> <label for="id">Id</label> <input type="text" <?php echo "value='{$album->AlbumId}'";
public function tambahfoto($id) { $album = Album::find($id); $detail = DB::table('detail_album')->where('id_album', '=', $id)->get(); return View::make('album.tambahfoto')->with('album', $album)->with('detail', $detail); }