本文整理汇总了PHP中Image::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::where方法的具体用法?PHP Image::where怎么用?PHP Image::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImages
public function getImages($option = array())
{
$images = Image::where("album_id", $this->id)->get();
if (!empty($option['width'])) {
foreach ($images as $index => $image) {
$width = getimagesize(public_path() . "/" . $image->path)[0];
if ($width > $option['width']) {
$images->forget($index);
}
}
}
if (!empty($option['height'])) {
foreach ($images as $index => $image) {
$height = getimagesize(public_path() . "/" . $image->path)[1];
if ($height > $option['width']) {
$images->forget($index);
}
}
}
if ($images->count() == 0) {
return array();
} else {
return $images;
}
}
示例2: store
public function store()
{
Notes::where('email', Auth::user()->email)->update(array('notes' => Input::get('notes')));
TBD::where('email', Auth::user()->email)->update(array('tbd' => Input::get('tbd')));
$input = Input::all();
for ($i = 0; $i < count($input); $i++) {
if (!Links::where('links', '=', Input::get("link{$i}"))->exists()) {
if (Input::get("link{$i}") != "") {
Links::insert(array('email' => Auth::user()->email, 'links' => Input::get("link{$i}")));
}
}
}
if (Input::hasFile('photo')) {
$count = Image::where('email', Auth::user()->email)->count();
if ($count >= 4) {
echo "USER CAN ONLY HAVE 4 PHOTOS MAX";
return Redirect::back();
}
$extension = Input::file('photo')->getClientOriginalExtension();
if ($extension == "gif" || $extension == "jpeg") {
Image::insert(array('email' => Auth::user()->email, 'image' => file_get_contents(Input::file('photo'))));
} else {
echo "CAN ONLY DO GIF OR JPEG";
}
}
$imageCount = Image::where('email', Auth::user()->email)->count();
for ($i = 0; $i < $imageCount - 1; $i++) {
if (Input::get("delete{$i}") != null) {
$imageTable = Image::where('email', Auth::user()->email)->get();
//echo $imageTable[$i+1]["id"];
Image::where('id', $imageTable[$i]["id"])->delete();
}
}
return Redirect::to('profile');
}
示例3: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->info('Checking all profile images...');
$images = Image::all();
foreach ($images as $image) {
// Send HEAD request
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_CUSTOMREQUEST, 'HEAD');
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_NOBODY, true);
curl_setopt($c, CURLOPT_URL, $image->author_image_url);
$res = curl_exec($c);
$this->info('ERROR HTTP CODE : ' . curl_getinfo($c, CURLINFO_HTTP_CODE));
// If 404 not found then delete from db
if (curl_getinfo($c, CURLINFO_HTTP_CODE) == 404) {
$this->info('Deleting: ' . $image->image_id);
$url = 'https://api.instagram.com/v1/users/search?q=' . $image->username . '&access_token=1040772762.5b9e1e6.7a7387aa92a546de86fde4fc4aec0d5b';
$ch = curl_init();
curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 2));
$result = curl_exec($ch);
curl_close($ch);
$results = json_decode($result, true);
$profile_picture = $results['data'][0]['profile_picture'];
$this->info('New Profile Picture : ' . $profile_picture);
Image::where('image_id', $image->image_id)->update(array('author_image_url' => $profile_picture));
$this->info('Update Complete' . $image->author_image_url);
}
}
}
示例4: getImageIdAttribute
public function getImageIdAttribute($value)
{
if ($value) {
$image = Image::find($value);
} else {
$image = Image::where('album_id', $this->id)->first();
}
return $image ? $image->thumburl : '';
}
示例5: imageDetail
/**
* Display detail of an image
*
* @param int $id
* @return Response
*/
public function imageDetail($id)
{
$image = Image::where('status', Constants::$COMMON_STATUSES['public'])->find($id);
if (empty($image)) {
App::abort('404');
}
$this->setViewData('model', $image);
return $this->createView('public.image-detail');
}
示例6: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->info('Updateing all usernames...');
// Get all the images
$images = Image::all();
// Loop over images to check each one exists
foreach ($images as $image) {
if ($image->username == "") {
$this->info('Update' . $image->image_id);
Image::where('image_id', $image->image_id)->update(['username' => substr($image->author_link_url, 21)]);
$this->info('Update Compelete ' . $image->username);
}
}
}
示例7: __construct
public function __construct($id = '', $width = '', $height = '')
{
// header('Content-Type: image/jpeg');
$this->ci =& get_instance();
$this->ci->config->load('cms/config');
$this->ci->load->library('Imagick');
$this->config = get_config();
//
$id = $id == '' ? null : $id;
$this->width = $width == '' ? null : $width;
$this->height = $height == '' ? null : $height;
// getImage Table DB
$this->image = \Image::where('id', $id)->first();
}
示例8: getLastTags
private function getLastTags($from, $threshold = 10)
{
$last_images = Image::where('created_at', '>=', $from)->get();
$last_tags = array();
foreach ($last_images as $image) {
$image_tags = $image->tags;
foreach ($image_tags as $tag) {
if ($tag->confidence < $threshold) {
continue;
}
array_push($last_tags, $tag);
}
}
return $this->getTags($last_tags);
}
示例9: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if (Auth::check()) {
//regenerate sessions after coming back so old session from before are replaced
Session::regenerate();
$note = Note::whereUser(Auth::user()->email)->first();
$images = Image::where('user', Auth::user()->email)->get();
$count = Image::where('user', Auth::user()->email)->get()->count();
$data = array('notes' => $note, 'user' => Auth::user()->email, 'images' => $images, 'count' => $count);
return View::make('sessions.home')->with($data);
} else {
return Redirect::route('sessions.create');
//form
}
}
示例10: index
public function index()
{
$user_id = Input::get('user_id');
$user = User::find($user_id);
if ($user) {
if (FEUsersHelper::isCurrentUser($user->id)) {
$images_d = Image::where('user_id', '=', $user->id);
} else {
$album_id = Album::where('user_id', '=', $user->id)->where('privacy', PrivaciesHelper::getId("Công khai"))->select('id')->get();
$images_d = Image::where('user_id', '=', $user->id)->whereIn('album_id', $album_id->fetch('id')->toArray());
}
return View::make('frontend/photos/images/index')->with('user', $user)->with('images', $images_d->paginate($this->image_per_page));
} else {
return Redirect::to('/');
}
}
示例11: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->deleteFiles(['thumbnail', 'gallery', 'origin', 'avatar_origin', 'avatar_large', 'avatar_middle', 'avatar_small']);
$s3 = AWS::get('s3');
$prefix = 'https://yolanothertest.s3-us-west-2.amazonaws.com/';
$objects = $s3->getIterator('listObjects', ['Bucket' => 'yolanothertest']);
foreach ($objects as $object) {
$imageUrl = $prefix . $object['Key'];
if ($thumbnail = Image::where('thumbnail', $prefix . $object['Key'])->whereNotNull('imageable_id')->first()) {
if ($thumbnail) {
File::append(storage_path('thumbnail.csv'), "{$thumbnail->id}, {$object['Key']}, {$thumbnail->imageable_type}, {$thumbnail->imageable_id}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
$this->line("{$thumbnail->id} thumbnail {$object['Key']} {$thumbnail->imageable_type} {$thumbnail->imageable_id} {$object['Size']}");
}
} elseif ($large = Image::where('regular', $prefix . $object['Key'])->whereNotNull('imageable_id')->first()) {
if ($large) {
File::append(storage_path('gallery.csv'), "{$large->id}, {$object['Key']}, {$large->imageable_type}, {$large->imageable_id}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
$this->line("{$large->id} gallery {$object['Key']} {$large->imageable_type} {$large->imageable_id} {$object['Size']}");
}
} elseif ($origin = Image::where('origin', $prefix . $object['Key'])->whereNotNull('imageable_id')->first()) {
if ($origin) {
File::append(storage_path('origin.csv'), "{$origin->id}, {$object['Key']}, {$origin->imageable_type}, {$origin->imageable_id}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
}
} elseif ($avatarOrigin = User::where('img_origin', $prefix . $object['Key'])->first()) {
if ($avatarOrigin) {
File::append(storage_path('avatar_origin.csv'), "{$avatarOrigin->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
}
} elseif ($avatarLarge = User::where('img_large', $prefix . $object['Key'])->first()) {
if ($avatarLarge) {
File::append(storage_path('avatar_large.csv'), "{$avatarLarge->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
}
} elseif ($avatarMiddle = User::where('img_middle', $prefix . $object['Key'])->first()) {
if ($avatarMiddle) {
File::append(storage_path('avatar_middle.csv'), "{$avatarMiddle->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
}
} elseif ($avatarSmall = User::where('img_small', $prefix . $object['Key'])->first()) {
if ($avatarSmall) {
File::append(storage_path('avatar_small.csv'), "{$avatarSmall->id}, {$object['Key']}, {$object['Size']}, " . $this->getImageSize($imageUrl) . PHP_EOL);
}
}
}
}
示例12: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$popular_media = $this->source->getPopularMedia();
// $images = Image::all();
// foreach($images as $image)
// {
// $request = \Httpful\Request::get($image->url)->send();
// if($request->hasErrors())
// {
// $image->delete();
// }
// }
foreach ($popular_media->data as $media) {
$post_link = $media->link;
$image_url = $media->images->standard_resolution->url;
$created_at = intval($media->created_time);
$image_count = Image::where('url', '=', $image_url)->count();
if ($image_count > 0) {
continue;
}
$tags = $this->getTags($image_url);
$image = new Image();
$image->url = $image_url;
$image->source = 'instagram';
$image->created_at = Carbon::now();
$image->post_url = $post_link;
$image->save();
$tags_objects = array();
foreach ($tags as $tag) {
$tag_object = new Tag();
$tag_object->name = $tag->tag;
$tag_object->confidence = $tag->confidence;
$tag_object->image()->associate($image);
$tag_object->save();
array_push($tags_objects, $tag_object);
}
$image->tags()->saveMany($tags_objects);
echo '.';
}
}
示例13: update
public function update($id)
{
if (!empty(Input::get('like')) && Input::get('like') == 'true') {
$image = Image::find($id);
$image->count_like = $image->count_like + 1;
$image->save();
echo 'true';
} else {
$data = Input::all();
$image = Image::where('id', $id)->first();
if (AlbumsHelper::save($data, $image->album->id)) {
$image->caption = $data['caption'];
if ($image->save()) {
Session::flash('status', 'success');
Session::flash('messages', array(0 => 'Updated'));
} else {
Session::flash('status', 'fail');
Session::flash('messages', array(0 => 'Failed'));
}
return Redirect::to('image/' . $image->id . '/edit');
}
}
}
示例14: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($order)
{
$success = 'not sure !';
// delete
$image = Image::where('gallery_id', '=', Input::get('gallery_id'))->where('order', '=', $order)->first();
if (empty($image)) {
return Redirect::to('admin/gallery/' . Input::get('gallery_id'))->with('error', 'Cette image n\'existe pas !');
}
$gallery = Gallery::find(Input::get('gallery_id'));
if ($image->id == $gallery->cover_id) {
$success = 'Vous avez supprimé la Cover de la Galerie ! Elle a été remplacé par la première image.';
}
//Regulation order in image
$image->delete();
DB::table('images')->where('gallery_id', '=', Input::get('gallery_id'))->where('order', '>', $order)->decrement('order');
if ($image->id == $gallery->cover_id) {
$gallery->cover_id = Image::where('gallery_id', '=', Input::get('gallery_id'))->where('order', '=', 0)->first()->id;
$gallery->save();
}
// redirect
$success .= ' L\'image a été supprimé !';
return Redirect::to('admin/gallery/' . Input::get('gallery_id'))->with('success', $success);
}
示例15: deleteAlbum
/**
* Delete an entire album
*
* @return boolean
*/
public function deleteAlbum()
{
try {
DB::beginTransaction();
// Get all the images in this album
// and physical deleting images
$images = $this->images;
if (!empty($images)) {
foreach ($images as $image) {
Utilities::deleteImageFile($image->name, true, $image->extension);
}
// Delete all record of images in this album
Image::where('album_id', $this->id)->delete();
}
// Delete this album
$this->delete();
DB::commit();
return true;
} catch (Exception $e) {
DB::rollback();
return false;
}
}