public function get_delete($id, $redirect = null) { $photo = Photo::find($id); $photo->delete(); if (is_null($redirect)) { return Redirect::to('admin/cityphotos')->with('msg', '<div class="alert alert-success"><strong>Foto verwijderd</strong></div>'); } }
public function viewDetails($id) { $photo = Photo::find($id); if ($photo === null) { $error = 'No such photo found.'; return View::make('errors.error', array('errorMsg' => $error)); } $comments = Comment::where('photo_id', '=', $photo->id)->with('author')->get(); return View::make('photo.details', array('photo' => $photo, 'comments' => $comments)); }
public function supprimerphotoAction() { if (isset($_GET['id'])) { $photo = new Photo(); $selectlaphoto = $photo->selectOne($_GET['id']); $photoname = $selectlaphoto['nomPhoto']; exec('rm ' . APPLICATION_PATH . '/../public/imgNao/' . $selectlaphoto['nomPhoto'], $output, $return); $laphoto = $photo->find($_GET['id'])->current(); $laphoto->delete(); $this->_redirect('/photovideo/photo'); } }
public function postPhotoComment($id) { $photo = Photo::find($id); if ($photo === null) { $error = 'Can not post comment. No such photo found.'; return View::make('errors.error', array('errorMsg' => $error)); } $input = Input::all(); $comment = new Comment(['content' => $input['content'], 'author_id' => Auth::user()->id, 'photo_id' => $id]); $comment->save(); return Redirect::to('/photo/' . $id); }
public function getPhotos() { $user = $this->request->user(); $profile = $user->profile; $gender = $profile->gender; $photos = $user->photos()->get(); if ($user->photo_id) { $photo = Photo::find($user->photo_id); $image = $photo->image->url('medium'); } else { $path = public_path(); $image = $path . ($gender ? '/img/avatars/' . $gender . sprintf('%02d', rand(1, 24)) . '.jpg' : '/img/avatars/user-default.jpg'); } return view('mypage.photos', compact('profile', 'photos', 'image')); }
public function dropphoto() { $lokasi = public_path() . '/photos'; $getId = Input::get('id'); if (!empty($getId)) { $delete = Photo::find($getId); $delete->delete(); try { unlink($lokasi . $getId . '_t.jpg'); unlink($lokasi . $getId . '.jpg'); return "ok"; } catch (Exception $e) { return "nothing _t.jpg"; } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $photo = Photo::find($id); //delete photos with thumbnails from file and photo from db foreach (Photo::getThumbnailSizes() as $key => $thumb) { File::delete(public_path('/uploads/' . $photo->user_id . "/") . $key . "-" . $photo->name); } File::delete(public_path('/uploads/' . $photo->user_id . "/") . $photo->name); $photo->delete(); $results = array($photo->name => true); return json_encode(array('files' => $results)); }
<? if ($image && null !== ($temp = Photo::find($image)) && is_object($temp)) $image = $temp; ?> <section class="b-title _long _invert" style="background-image: url({{ $image->full() }});"> <div class="b-title__logo _invisible"> <img src="{{ Config::get('site.theme_path') }}/img/logo/ikra-top.png" alt="ИКРА IKRA"> </div> <div class="b-title__text"> <h1 class="_mb30">{{ $current_city->name }}</h1> <i><strong>{{ $current_city->address }}</strong></i> </div> </section>
public function testPolymorphicHasManyLoad() { $photo = Photo::find(1); $this->assertEquals(2, $photo->comments->length); }
echo "<br />"; echo $rc->to_xml(); $users = User::find_all(); $user = $users[0]; echo '<pre>'; print_r($users); var_dump($user); echo 'photos<br/>'; foreach ($user->photos() as $photo) { print_r($photo); echo "id<p>"; echo $photo->id(); echo "<p> " . $photo->file() . " </p>"; } echo 'end photos<br/>'; $photos2 = Photo::find(array(1, 2)); var_dump($photos2); echo "USer start<br/>"; var_dump($photos2[0]->user()); echo "user end<br/>"; $user2 = User::find($user->id()); var_dump($user2); var_dump($user2->photos()); try { $user3 = User::find(4); var_dump($user3); } catch (\ActivePhp\RecordNotFound $e) { echo 'execption caught<br/>'; echo '<br/>'; } echo "Photo count<br/>";
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $photo = Photo::find($id); //Delete object from S3 Bucket $s3 = AWS::get('s3'); $s3->deleteObject(array('Bucket' => 'images.jacksonlive.es', 'Key' => "test/high/{$photo->file}")); $s3->deleteObject(array('Bucket' => 'images.jacksonlive.es', 'Key' => "test/low/{$photo->file}")); $photo->delete(); return Redirect::route('photo.index'); }
<?php $id = $resource->id; $photo_id = $resource->def_photo_id; if ($photo_id == 0) { $photoResId = $resource->photoIds()->first(); if (empty($photoResId)) { $photoUrl = 'img/8.png'; } else { $photoId = $photoResId->photo_id; $photoUrl = Photo::find($photoId)->url; } if (empty($photoUrl)) { $photoUrl = 'img/8.png'; } } else { $photoUrl = Photo::find($photo_id)->url; } ?> <a href="{{ URL::to('resources/' . $resource->id) }}" data-path-hover="m 0,0 0,47.7775 c 24.580441,3.12569 55.897012,-8.199417 90,-8.199417 34.10299,0 65.41956,11.325107 90,8.199417 L 180,0 z"> <figure> {{HTML::image($photoUrl, $alt = 'Second image', array('class' => 'img responsive'))}} <svg viewBox="0 0 180 320" preserveAspectRatio="none"><path d="m 0,0 0,171.14385 c 24.580441,15.47138 55.897012,24.75772 90,24.75772 34.10299,0 65.41956,-9.28634 90,-24.75772 L 180,0 0,0 z"/></svg> <figcaption> <h2>{{ $resource->name }}</h2> <p>{{substr($resource->description,0,50)."....."}}</p> </figcaption> </figure> </a> @endforeach
/** * Ссылка на изображение, подвергнутое кропу или ресайзу * * URL::route('image.resize', [$photo->id, 200, 200]) * URL::route('image.resize', [$photo->id, 200, 200, 'r']) * * См. также /app/config/site.php * - galleries_cache_public_dir * - galleries_cache_allowed_sizes * * @param string $method Method of resize - crop or resize */ public function getImageResize($image_id, $w, $h, $method = 'crop') { $image = $image_id ? Photo::find($image_id) : null; #Helper::tad($method); /** * Костылек-с */ if (is_numeric($method)) { $h = $h * 10 + $method; #$method = 'crop'; } if ($method == 'r') { $method = 'resize'; } else { $method = 'crop'; } #Helper::tad($method); /** * Соблюдены ли все правила? */ if (!$image_id || !$image || !is_object($image) || !@file_exists($image->fullpath()) || !$w || !$h || $w < 0 || $h < 0 || !in_array($w . 'x' . $h, (array) Config::get('site.galleries_cache_allowed_sizes')) || !in_array($method, ['crop', 'resize'])) { App::abort(404); } /* Helper::ta($image_id . '_' . $w . 'x' . $h . $method . '.jpg'); Helper::ta($image->fullpath()); Helper::ta($image->fullcachepath($w, $h, $method)); Helper::ta($image->cachepath($w, $h, $method)); #Helper::tad($image->full()); */ if (!File::exists(Config::get('site.galleries_cache_dir'))) { File::makeDirectory(Config::get('site.galleries_cache_dir'), 0777, TRUE); } $img = ImageManipulation::make($image->fullpath()); if ($method == 'resize') { /** * Resize + Resize Canvas */ $img->resize($w, $h, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); $img->resizeCanvas($w, $h); /* $newimg = ImageManipulation::canvas($w, $h); $newimg->insert($img, 'center'); $img = $newimg; #$newimg->destroy(); #*/ } else { /** * Resize + Crop */ /** * Текущие значения ширины и высоты */ $rw = $img->width(); $rh = $img->height(); /** * Находим требуемые коэффициенты */ $c1 = $rw / $w; ## Делим реальную ширину на желаемую $c2 = $rh / $h; ## Делим реальную высоту на желаемую /** * Если c1 < c2 - то ресайзить нужно по ширине * Если c1 > c2 - то ресайзить нужно по высоте */ if ($c1 < $c2) { /** * Ресайзим по меньшей стороне, по ширине */ $nw = $w; $nh = null; } else { /** * Ресайзим по меньшей стороне, по высоте */ $nw = null; $nh = $h; } #Helper::tad($nw . 'x' . $nh); $img->resize($nw, $nh, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); }); /** * Новые значения ширины и высоты, после ресайза по меньшей стороне */ $nnw = $img->width(); $nnh = $img->height(); /** * Кроп по центру по заданным размерам */ $img->crop($w, $h, ceil(($nnw - $w) / 2), ceil(($nnh - $h) / 2)); } /** * Сохраняем изображение */ $img->save($image->fullcachepath($w, $h, $method), 90); /** * Отдаем изображение в браузер */ header('Debug-ImageSource: onthefly'); return $img->response(); }
public static function recordImageBy($type_name, $type_id) { try { $check = Photo::where('type_name', $type_name)->where('type_id', $type_id)->count(); if ($check == 1) { $getId = Photo::where('type_name', $type_name)->where('type_id', $type_id)->get(); $update = Photo::find($getId[0]->id); $update->name = $name; $update->type_name = $type_name; $update->type_id = $type_id; $update->status = 1; $update->save(); } else { $post = new Photo(); $post->name = $name; $post->type_name = $type_name; $post->type_id = $type_id; $post->status = 1; $post->save(); } return "ok"; } catch (Exception $e) { return "no"; } }
<?php require '../config/database.php'; require 'user.php'; require 'photo.php'; // start session session_start(); require 'helpers.php'; // some helpers require sessions // must be authorized to view this page must_be_authorized(); if ($_POST) { $photo = Photo::find($_POST['id']); $photo->vote(); } $photos = Photo::random_vs(); ?> <?php include 'views/_header.php'; ?> <?php include 'views/_navi.php'; ?> <h2>Vote on a Photo</h2> <?php foreach ($photos as $photo) { ?> <div class="versus_photo">
public static function moveImagesToGallery($images = array(), $gallery_id = false) { if (!isset($images) || !is_array($images) || !count($images)) { return $gallery_id; } ## Find gallery $gallery = $gallery_id ? Gallery::find($gallery_id) : null; ## If gallery not found - create her if (!$gallery) { $gallery = Gallery::create(array('name' => 'noname')); } ## Get gallery ID $gallery_id = $gallery->id; ## Move all images to gallery foreach ($images as $i => $img_id) { $img = Photo::find($img_id); if (@$img) { $img->gallery_id = $gallery_id; #print_r($img); $img->save(); } } return $gallery_id; }
public function view($id) { // get our post, identified by the route // parameter $photo = Photo::find($id); $photo->views += 1; $photo->save(); // show the full view, and pass the post // we just aquired return View::make('photo.view')->with('photo', $photo); }