本文整理汇总了PHP中Album::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::where方法的具体用法?PHP Album::where怎么用?PHP Album::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: albumDetail
/**
* Display detail of an album
*
* @param int $id
* @return Response
*/
public function albumDetail($id)
{
// Find album by ID
$album = Album::where('status', Constants::$COMMON_STATUSES['public'])->find($id);
if (empty($album)) {
return App::abort('404');
}
$images = $album->publicImages()->paginate($this->pageSize);
$this->setViewData('model', $album);
$this->setViewData('images', $images);
return $this->createView('public.album-detail');
}
示例2: getViewProfileDatas
private function getViewProfileDatas($user_id)
{
$privacy = Privacy::where('name', "Công khai")->get()->first();
$datas = array();
if (FEUsersHelper::isCurrentUser($user_id)) {
$entries = Entry::where('user_id', $user_id)->orderBy('updated_at', 'DESC')->paginate($this->entries_per_page);
$left_albums = Album::where('user_id', $user_id)->orderBy('updated_at', 'DESC')->get();
} else {
$entries = Entry::where('user_id', $user_id)->where('privacy', $privacy->id)->orderBy('updated_at', 'DESC')->paginate($this->entries_per_page);
$left_albums = Album::where('user_id', $user_id)->where('privacy', 1)->orderBy('updated_at', 'DESC')->get();
}
return array("entries" => $entries, "left_albums" => $left_albums);
}
示例3: getView
public function getView($id)
{
$album = Album::where('id', '=', $id)->first();
$pictures = Picture::where('album_id', '=', $id)->orderBy('votes', 'desc')->paginate(12);
// layouts variables
$this->layout->title = $album->name . ' | Нещо Шантаво';
$this->layout->canonical = 'https://neshto.shantavo.com/album/' . $id;
$this->layout->robots = 'index,follow,noodp,noydir';
$this->layout->description = 'Това е албум';
$this->layout->keywords = 'начало, нещо шантаво, team navy pier';
// nesting the view into the layout
$this->layout->nest('content', 'album.view', array('album' => $album, 'pictures' => $pictures));
}
示例4: index
public function index()
{
$user_id = Input::get('user_id');
$user = User::find($user_id);
if ($user) {
if (FEUsersHelper::isCurrentUser($user->id)) {
$albums_d = Album::where('user_id', '=', $user->id);
} else {
$albums_d = Album::where('user_id', '=', $user->id)->where('privacy', PrivaciesHelper::getId("Công khai"));
}
return View::make('frontend/photos/albums/index')->with('user', $user)->with('albums', $albums_d->paginate($this->album_per_page));
} else {
return Redirect::to('/');
}
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$data = Input::except(array('_token', '_method'));
$trimmedData = $this->trimData($data, array());
$album = Album::where('name', $trimmedData['name'])->get()->first();
if (!empty($album)) {
Session::flash('flash_error', trans('message.album.error.already_exist'));
return Redirect::route('secured.album.create')->withInput();
}
$currentUser = $this->getCurrentUser();
$album = new Album();
$album->fill($trimmedData);
$album->owner_id = $currentUser->id;
if (!$album->save()) {
$errors = $album->errors();
return Redirect::route('secured.album.create')->withInput()->withErrors($errors);
}
return Redirect::route('secured.album.index');
}
示例6: index
public function index()
{
$datas = Input::all();
$params = array();
if (isset($datas['u'])) {
$params['user_id'] = $datas['u'];
}
if (isset($datas['title'])) {
$params['title'] = $datas['title'];
}
if (isset($datas['category'])) {
$params['category_id'] = $datas['category'];
}
$albums_d = Album::where('public', '=', '1');
foreach ($params as $key => $param) {
if ($key == 'title') {
$op = 'LIKE';
$param = "%" . $param . "%";
}
if ($key == 'user_id' || $key == 'category_id') {
$op = '=';
}
$albums_d = Album::where($key, $op, $param);
}
if (Input::get('s') == 'like') {
$albums = $albums_d->orderBy('updated_at', 'DESC')->get()->sortBy(function ($album) {
return $album->images->sum('count_like');
}, SORT_REGULAR, true);
} else {
$albums = $albums_d->orderBy('updated_at', 'DESC')->get();
}
if (!empty($params['user_id'])) {
$view = View::make('frontend/albums/my-images')->with('albums', $albums);
} else {
$view = View::make('frontend/index')->with('albums', $albums);
}
if (!empty($params['category_id'])) {
$view->with('category_title', Category::find($params['category_id'])->title);
}
return $view;
}
示例7: collectoinAlbumIsEmpty
public function collectoinAlbumIsEmpty()
{
$collection = Album::where('title', '=', 'foo')->get();
var_dump($collection->isEmpty());
}
示例8: editAlbum
public function editAlbum()
{
if (!Auth::check()) {
return Response::json(array('errCode' => 1, 'message' => '请登录'));
}
$album_id = Input::get('album_id');
$name = Input::get('album_name');
$validation = Validator::make(array('name' => $name), array('name' => 'required'));
if ($validation->fails()) {
return Response::json(array('errCode' => 2, 'message' => '请填写相册名字'));
}
$album = Album::where('id', '=', $album_id)->first();
if ($album == null) {
return Response::json(array('errCode' => 3, 'message' => '相册不存在!'));
}
if ($album->user_id != Auth::user()->id) {
return Response::json(array('errCode' => 4, 'message' => '不可以修改他人的相册!'));
}
$album->title = $name;
if ($album->save()) {
return Response::json(array('errCode' => 0, 'message' => '相册名修改成功!'));
}
return Response::json(array('errCode' => 4, 'message' => '相册名修改失败!'));
}
示例9: aggregate
function aggregate($type, $options = array())
{
$options = array_merge(array('featured' => false), $options);
$shared_params = array();
if ($type === 'tag') {
$shared_params['tags'] = $options['tag_slug'];
} else {
if ($type === 'category') {
$shared_params['category'] = $options['category'];
}
}
$album_params = $shared_params;
$date_marker = false;
if ($type === 'date') {
$s = new Setting();
$s->where('name', 'site_timezone')->get();
$tz = new DateTimeZone($s->value);
$offset = $tz->getOffset(new DateTime('now', new DateTimeZone('UTC')));
if ($offset === 0) {
$shift = '';
} else {
$shift = ($offset < 0 ? '-' : '+') . abs($offset);
}
// Need to - the offset here, as we need to shift this timestamp by the inverse of the offset to match DB UTC time.
// For example. Midnight in user's time (say, CT -5) is UTC+5.
$album_params['before'] = $date_marker = strtotime("{$options['year']}-{$options['month']}-{$options['day']} 23:59:59") - $offset;
}
$aggregate = $essay_ids = $album_ids = $content_ids = $updated_album_ids = $exclude_albums = $exclude_content = $sets = $range = array();
$t = new Text();
$t->select('id, featured, featured_image_id, published_on')->where('page_type', 0)->where('published', 1);
if ($type === 'date') {
$t->where("YEAR(FROM_UNIXTIME({$t->table}.published_on{$shift}))", $options['year'])->where("MONTH(FROM_UNIXTIME({$t->table}.published_on{$shift}))", $options['month'])->where("DAY(FROM_UNIXTIME({$t->table}.published_on{$shift}))", $options['day']);
} else {
if ($type === 'tag') {
$t->where_related('tag', 'id', $options['tag']);
} else {
$t->where_related('category', 'id', $options['category']);
}
}
if ($options['featured']) {
$t->where('featured', 1);
}
$t->include_related('album', 'id')->order_by($t->table . '.published_on DESC')->get_iterated();
foreach ($t as $essay) {
$essay_ids[$essay->id] = $essay->published_on;
$aggregate[] = array('type' => 'essay', 'id' => $essay->id, 'date' => $essay->published_on, 'featured' => $essay->featured);
if ($essay->album_id) {
$exclude_albums[] = $essay->album_id;
}
if (is_numeric($essay->featured_image_id)) {
$exclude_content[] = $essay->featured_image_id;
}
}
$a = new Album();
$a->select('id, featured, published_on, left_id, right_id, level')->where('visibility', 0)->where('deleted', 0)->where('total_count >', 0);
if ($type === 'date') {
$a->where("YEAR(FROM_UNIXTIME({$a->table}.published_on{$shift}))", $options['year'])->where("MONTH(FROM_UNIXTIME({$a->table}.published_on{$shift}))", $options['month'])->where("DAY(FROM_UNIXTIME({$a->table}.published_on{$shift}))", $options['day']);
} else {
if ($type === 'tag') {
$a->where_related('tag', 'id', $options['tag']);
} else {
$a->where_related('category', 'id', $options['category']);
}
}
if ($options['featured']) {
$a->where('featured', 1);
}
$a->include_related('content', 'id')->order_by($a->table . '.published_on DESC')->get_iterated();
foreach ($a as $album) {
if (is_numeric($album->content_id)) {
$exclude_content[] = $album->content_id;
}
if (!array_key_exists($album->id, $album_ids) && !in_array($album->id, $exclude_albums)) {
$album_ids[$album->id] = $album->published_on;
$aggregate[] = array('type' => 'album', 'id' => $album->id, 'date' => $album->published_on, 'featured' => $album->featured);
}
if ($album->level < 2) {
$range = array_merge($range, range($album->left_id, $album->right_id));
}
if ($album->level > 1) {
$sets[$album->id] = $album->left_id;
}
}
foreach ($sets as $id => $left) {
if (in_array($left, $range)) {
unset($album_ids[$id]);
foreach ($aggregate as $i => $info) {
if ($info['type'] === 'album' && $info['id'] == $id) {
unset($aggregate[$i]);
}
}
}
}
$c = new Content();
$c->select('id, published_on, featured');
if (!empty($exclude_content)) {
$c->where_not_in('id', $exclude_content);
}
$c->where('visibility', 0)->where('deleted', 0);
if ($type === 'date') {
//.........这里部分代码省略.........
示例10: processUploadImage
/**
* Process upload image file to server and save to database
*
* @param int $albumId
* @param array $errors
*/
private function processUploadImage($albumId, &$errors)
{
if (!Input::hasFile('imageFile')) {
$errors = trans('message.common.error.file_not_found');
return false;
}
$currentUser = $this->getCurrentUser();
// Find album
$album = Album::where('id', $albumId)->where('owner_id', $currentUser->id)->get()->first();
if (empty($album)) {
$errors = trans('message.album.error.album_not_found');
return false;
}
$file = Input::file('imageFile');
// Upload image file to server and create thumbnail image
$uploadedFileName = Utilities::uploadFile($file);
if (empty($uploadedFileName)) {
$errors = trans('message.common.error.upload_failed');
return false;
}
// Save data to database
$extension = $file->getClientOriginalExtension();
$model = new Image();
$model->name = $uploadedFileName;
$model->extension = $extension;
$model->album_id = $albumId;
$model->status = Input::get('status');
if (!$model->save()) {
$errors = $model->errors();
return false;
}
return true;
}
示例11: getAlbums
public function getAlbums()
{
if (Auth::guest()) {
return Redirect::secure('/');
}
// layouts variables
$this->layout->title = 'Албуми | Нещо Шантаво';
$this->layout->canonical = 'https://neshto.shantavo.com/user/albums';
$albums = Album::where('user_id', '=', Auth::user()->id)->get();
$categories = Category::all();
// nesting the view into the layout
$this->layout->nest('content', 'user.albums', array('albums' => $albums, 'categories' => $categories));
}
示例12: Album
<?php
$albums = new Album();
$albums->where('listed', 0)->get();
$albums->update_all('visibility', 1);
$done = true;
示例13: index
function index()
{
list($params, $id, $slug) = $this->parse_params(func_get_args());
// Create or update
if ($this->method != 'get') {
$c = new Content();
switch ($this->method) {
case 'post':
case 'put':
if ($this->method == 'put') {
// Update
$c->get_by_id($id);
if (!$c->exists()) {
$this->error('404', "Content with ID: {$id} not found.");
return;
}
$c->old_published_on = $c->published_on;
$c->old_captured_on = $c->captured_on;
$c->old_uploaded_on = $c->uploaded_on;
if (isset($_POST['slug'])) {
$c->current_slug = $c->slug;
}
}
if (isset($_REQUEST['name'])) {
if (isset($_REQUEST['upload_session_start'])) {
$s = new Setting();
$s->where('name', 'last_upload')->get();
if ($s->exists() && $s->value != $_REQUEST['upload_session_start']) {
$s->value = $_REQUEST['upload_session_start'];
$s->save();
}
}
$file_name = $c->clean_filename($_REQUEST['name']);
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
$tmp_dir = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
$tmp_path = $tmp_dir . DIRECTORY_SEPARATOR . $file_name;
make_child_dir($tmp_dir);
if ($chunks == 0 || $chunk == $chunks - 1) {
if (isset($_REQUEST['text'])) {
$path = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR;
$internal_id = false;
} else {
if (isset($_REQUEST['plugin'])) {
$info = pathinfo($_REQUEST['name']);
$path = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $_REQUEST['plugin'] . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR;
$file_name = $_REQUEST['basename'] . '.' . $info['extension'];
$internal_id = false;
} else {
list($internal_id, $path) = $c->generate_internal_id();
}
}
if ($path) {
$path .= $file_name;
if ($chunks == 0) {
$tmp_path = $path;
}
} else {
$this->error('500', 'Unable to create directory for upload.');
return;
}
}
// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
} else {
if (isset($_SERVER["CONTENT_TYPE"])) {
$contentType = $_SERVER["CONTENT_TYPE"];
} else {
$contentType = '';
}
}
if (strpos($contentType, "multipart") !== false) {
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
$out = fopen($tmp_path, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen($_FILES['file']['tmp_name'], "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
} else {
$this->error('500', 'Unable to read input stream.');
return;
}
fclose($out);
unlink($_FILES['file']['tmp_name']);
} else {
$this->error('500', 'Unable to write to output file.');
return;
}
} else {
$this->error('500', 'Unable to move uploaded file.');
return;
}
} else {
$out = fopen($tmp_path, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
//.........这里部分代码省略.........
示例14: getView
public function getView($id)
{
$data['category'] = Category::where('id', $id)->first();
$data['albums'] = Album::where('category_id', $id)->where('public', '=', 1)->get();
return View::make('frontend/categories/view')->with('data', $data);
}
示例15: Album
<?php
$albums = new Album();
$albums->where('sort', '[object Object]')->get();
$albums->update_all('sort', 'manual ASC');
$done = true;