/** * Display the instructor profile. * * @return Response */ public function getProfile($id = Null) { if (isset($id)) { //The instructor with the given user_id $instructor = User::with('instructor')->has('instructor')->where('active', 1)->find($id); if (count($instructor) == 1) { //Instructor_id of the instructor $instructor_id = $instructor->instructor->instructor_id; //All reviews of the instructor $reviews = Instructor::find($instructor_id)->reviews()->orderBy('created_at', 'desc')->paginate(2); $reviews->setPath('/drive/instructor/profile/83/url'); //Counting the number of reviews wrote by the current learner for the instructor // $no_of_review = Review::where('learner_id', Auth::user()->learner->learner_id)->where('Instructor_id', $instructor_id)->count(); //Counting total number of reviews of the instructor $total_reviews = Instructor::find($instructor_id)->reviews()->count(); //Calculating the average rating $avg_rating = Instructor::find($instructor_id)->reviews()->avg('rating'); // $images = Image::where('instructor_id', $instructor_id)->get(); //Returning the view with $instructors return view('instructor_profile', ['instructor' => $instructor, 'reviews' => $reviews, 'total_reviews' => $total_reviews, 'avg_rating' => $avg_rating, 'images' => $images]); } else { //If no result, redirect the user to the instructor_list //Flashed data contains message and alert-danger class return redirect()->action('InstructorController@getIndex')->with('message', 'No instructor profile found!')->with('alert-class', 'alert-danger'); } //End of if statement } else { //If no id provided, redirect the user to the instructor_list return redirect()->action('InstructorController@getIndex'); } //End of if statement }
/** * Save product to database */ public function save() { $data = ['item_id' => $this->item_id, 'shop_id' => $this->shop_id] + $this->data; if (!App\Product::where('shop_id', $this->shop_id)->where('item_id', $this->item_id)->update($this->data) && !App\Product::insert($data)) { return false; } $this->id = App\Product::where('shop_id', $this->shop_id)->where('item_id', $this->item_id)->first()->id; if (!$this->id) { return false; } foreach ($this->images as $image) { if (!App\Image::where('url', $image['url'])->update($image) && !App\Image::insert($image + ['product_id' => $this->id])) { return false; } } /*if( isset( $this->params ) ) { foreach( $this->params as $param ) { if( !App\Param::where( 'param', $param['param'] )->update( $param ) && !App\Param::insert( $param + [ 'product_id' => $this->id ] ) ) return false; } }*/ return true; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // $images = Image::where('page_id', '=', $_GET)->get(); $possible_photos = PossiblePhoto::orderBy('created_at', 'ASC')->get(); return view('images.index', compact('images', 'possible_photos')); }
public function getImages() { $user = Auth::User(); $userID = $user->id; $getImages = Image::where('userID', $userID)->get(); return $getImages; }
protected function makeImage($file, $height, $width, $randomFilename, $thumbnail = null) { $md5 = md5_file($file->getRealPath()); $img = Image::make($file)->fit($height, $width); $path = 'images/'; if ($thumbnail != null) { $path = 'images/thumb/'; } $image = Images::where('md5_hash', $md5)->first(); if ($image === null or $image->thumbnail_file == null) { Clockwork::info('Storing on Filesystem'); $img->save(storage_path() . '/app/' . $path . $randomFilename . '.png', 90); } if ($image === null and $thumbnail === null) { Clockwork::info('New Image'); $image = new Images(); $image->user_id = Auth::user()->id; $image->filename = $file->getClientOriginalName(); $image->file = $randomFilename . '.png'; $image->height = $height; $image->width = $width; $image->md5_hash = $md5; } elseif ($thumbnail != null and $image->thumbnail_file == null) { Clockwork::info('Thumbnail Updated'); $image->thumbnail_file = $randomFilename . '.png'; } $image->save(); return $image; }
function getExample3() { $images = \App\Image::where('date_taken', '<', '2000-00-00')->get(); foreach ($images as $image) { echo $image->narrative . '<br>'; } dump($images); }
/** * Show a image based on on the filename * @param $filename * @return mixed */ public function show($filename) { $file = Image::where('filename', $filename)->firstOrFail(); if (!$file) { return $this->respondWithError(); } return Fractal::item($file, new \App\Transformers\ImageTransformer())->responseJson(200); }
/** * @return $this */ public function meta() { $img_url = 'http://d14d0ey1pb5ifb.cloudfront.net/'; $property = \App\Property::where(['meta_set' => 0, 'status' => '1'])->orderBy('package', 'DESC')->first(); $address = \App\Address::where(['property_id' => $property->property_id])->first(); $images = \App\Image::where(['property_id' => $property->property_id])->orderBy('pos', 'ASC')->get(); return view('dashboard.meta')->with(compact(['property', 'address', 'images', 'img_url'])); }
public function kill() { $image = Image::where('model_name', '=', 'Article')->where('foreign_id', '=', $this->id)->first(); if (!empty($image)) { $image->kill(); } $this->delete(); }
public function afficher($id_image) { if (Image::find($id_image)) { return View::make('image', ['image' => Image::find($id_image), 'precedente' => Image::where('id_image', '<', Image::find($id_image)->id_image)->where('id_campagne', '=', Image::find($id_image)->id_campagne)->max('id_image'), 'suivante' => Image::where('id_image', '>', Image::find($id_image)->id_image)->where('id_campagne', '=', Image::find($id_image)->id_campagne)->min('id_image')]); } else { return Response('Image non trouvée'); } }
public function roomHistory($room_id) { $room_contracts = Contract::withTrashed()->where('room_id', $room_id)->select('id', 'contractor_name', 'phone', 'end_water_degree', 'end_electric_degree', 'start_time', 'end_time', 'real_end_time')->get(); foreach ($room_contracts as &$contract) { $images = Image::where('r_id', $contract['id'])->select('path as img', 'imageable_id', 'r_id')->get(); $contract['images'] = $images; } return $room_contracts; }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Family $family) { $id = $family->id; $mother = Person::latest('created_at')->where('id', '=', $family->mother_id)->first(); $father = Person::latest('created_at')->where('id', '=', $family->father_id)->first(); $kids = FamilyController::get_kids_of_family($family); $images = Image::where('family', $id)->orderBy('year', 'asc')->get(); $featured_image = Image::latest('created_at')->orderBy('year', 'asc')->Where('family', $id)->Where('featured', 1)->get(); return view('family.show', compact('family', 'kids', 'images', 'mother', 'father', 'featured_image')); }
public function show(Person $person) { $logged_in_user = \Auth::user(); $id = $person->id; $solo_images = Image::where('subject', $id)->orderBy('year', 'asc')->get(); $featured_image = Image::where('subject', $id)->orderBy('year', 'asc')->Where('featured', 1)->get(); $made_family = PeopleController::get_made_family($person); $notes = PeopleController::get_notes_about_person($person); $origin_family = Family::where('id', $person->family_of_origin)->first(); return view('person.show', compact('person', 'solo_images', 'made_family', 'featured_image', 'origin_family', 'notes', 'logged_in_user')); }
/** * Get image from storage * * @param Request $request * @return file */ public function getImage(Request $request) { /** * Check the cache */ $cacheKey = 'image:' . $request->imageName . ':' . $request->imageExtension; /** * File cached */ if (Cache::has($cacheKey)) { $imageMeta = Cache::get($cacheKey); } else { /** * Get META information */ $imageMeta = Image::where(['url' => $request->imageName, 'image_extension' => $request->imageExtension])->first(['image_mime_type', 'image_size', 'id', 'updated_at', 'image_etag']); /** * File does not exist */ if (empty($imageMeta) == TRUE) { App::abort(404); } /** * Save meta information to cache */ Cache::forever($cacheKey, $imageMeta); } /** * Get filename */ $filename = Helpers::getStorageFilename(env('APP_IMAGE_STORAGE_DIRECTORY', 'images'), $imageMeta->id); /** * Prepare stream */ $stream = Storage::readStream($filename); /** * File headers */ $headers = array('Content-Description' => 'File Transfer', 'Content-Type' => $imageMeta->image_mime_type, 'Content-Transfer-Encoding' => 'binary', 'Pragma' => 'public', 'Expires' => Carbon::createFromTimestamp(time() + 3600)->toRfc2822String(), 'Last-Modified' => $imageMeta->updated_at->toRfc2822String(), 'Etag' => $imageMeta->image_etag); /** * Response code cached */ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $imageMeta->image_etag || isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $imageMeta->updated_at->toRfc2822String()) { $responseCode = 304; } else { $responseCode = 200; } /** * Stream to browser */ return Response::stream(function () use($stream) { fpassthru($stream); }, $responseCode, $headers); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // return the rental and urls for the images $rental = \App\Rental::find($id); $images = \App\Image::where('project_id', '=', $id)->get(); $image_response = []; foreach ($images as $image) { array_push($image_response, ['url' => config('app.url') . "/images/" . $image->id]); } $rental['images'] = $image_response; return response()->json(['rental' => $rental]); }
public function rechercher($id_campagne, Request $request) { $campagne = Campagne::find($id_campagne); $contenu = $request::get('recherche'); if ($campagne != null) { return view('campagne', ['campagne' => $campagne, 'images' => Image::where('id_campagne', $id_campagne, false)->where(function ($query) use($contenu) { $query->where('titre_image', 'LIKE', '%' . $contenu . '%')->orWhere('description_image', 'LIKE', '%' . $contenu . '%'); })->where('validation_image', 1, false)->orderByRaw('RAND()')->get(), 'elementRecherche' => $contenu]); } else { return Response("Campagne non trouvée"); } }
/** * Show the form for creating a new Cruiseline. * * @return View */ public function create() { $rankings = Ranking::where('rankable_type', '=', 'App\\Image')->get(); $labels = Label::where('status', '=', '1')->where('type', '=', 'Image')->orderBy('name', 'ASC')->get(); foreach ($labels as $label) { $images[$label['name']] = Image::where('status', '=', '1')->where('product', '=', 0)->where('label_id', '=', $label['id'])->orderBy('name', 'ASC')->lists('name', 'id'); } if (count($rankings)) { return view('galleryrankings.create', compact('images', 'rankings')); } return view('galleryrankings.create', compact('images')); }
/** * @return mixed */ public function getProvince() { $province = Input::get('province'); if (Input::has('year')) { $year = Input::get('year'); } else { $year = 2014; } $result = Province::where('province', '=', $province)->where('year', '=', $year)->first(); $img = Image::where('province', '=', $province)->first(); $image = $img->image; return View::make('public.province')->with('province', $result)->with('image', $image)->with('year', $year); }
/** * Run the database seeds. * * @return void */ public function run() { // Create an array of the images we want to associate tags with. $images = ["2014-07-23-1015.jpg" => ['Spiti', 'Himachal Pradesh', 'trohloff'], "2014-07-23-1045.jpg" => ['Spiti', 'Himachal Pradesh', 'trohloff'], "2014-07-29-1270.jpg" => ['Keylong', 'Himachal Pradesh', 'trohloff'], "2013-06-09-0871.jpg" => ['Leh', 'Himachal Pradesh', 'Ladakh'], "2013-06-02-0157.jpg" => ['Indian Railways', 'Himachal Pradesh', 'narrow-gauge'], "2013-06-07-0712.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Buddhism', 'prayer flags', 'Leh'], "2013-06-07-0749.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Buddhism', 'prayer flags', 'Leh'], "2013-06-10-0928.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Buddhism', 'monastery'], "2013-06-12-1101.jpg" => ['Ladakh', 'Jammu & Kashmir'], "2013-06-14-1448.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Khardung La', 'Leh'], "2013-06-15-1607.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Khardung', 'Buddhism'], "2013-06-15-1625.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Khardung'], "2013-06-16-1701.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Nubra Valley'], "2013-06-16-1706.jpg" => ['Ladakh', 'Jammu & Kashmir', 'Nubra Valley']]; // Loop through the above array, creating a new pivot for each image to a tag foreach ($images as $filename => $tags) { $image = \App\Image::where('filename', 'like', $filename)->first(); foreach ($tags as $tagName) { $tag = \App\Tag::where('name', 'LIKE', $tagName)->first(); $image->tags()->save($tag); } } }
/** * Save a file to the database. * * @param File $file * @return string */ public function save(File $file) { $image = file_get_contents($file); $hash = sha1($image); $model = Image::where('hash', $hash)->first(); if (!$model) { $model = Image::create(['hash' => $hash, 'image' => $image]); } unset($image); unset($file); if ($model) { return $this->url($model->id); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // this id will be article id, be careful $images = HomeImage::where('article_id', '=', $id)->get(); $categories = Category::all(); $article = Article::findOrFail($id); $articlesNumber = CategoriesController::getCategoryArticle(); /** * Need refactory */ $comments = DB::table('comments')->join('users', 'users.id', '=', 'comments.user_id')->where('article_id', '=', $id)->orderBy('comments.created_at', 'desc')->select('comments.*', 'users.name')->get(); // dd($images); return view('articles.show', compact('categories', 'article', 'comments', 'articlesNumber', 'images')); }
public function searchImage(Request $request) { $images = Image::where('title', 'like', "%" . $request->input('title') . "%"); $tags = Tag::where('id', '>', 0)->get(); $phototags = PhotoTag::where('image_id', '>', 0)->get(); $requestSave['title'] = $request->input('title'); $requestSave['typeCheck'] = $request->input('typeCheck'); $requestSave['type'] = $request->input('type'); $requestSave['ownerCheck'] = $request->input('ownerCheck'); $requestSave['owner'] = $request->input('owner'); $requestSave['ownerCheck'] = $request->input('sizeCheck'); $requestSave['owner'] = $request->input('size'); if ($request->input('typeCheck') != null) { $types = $_GET['type']; foreach ($types as $type) { $ptags = PhotoTag::where('tag_id', 'like', "%" . $type . "%")->get(); $arr = array(); foreach ($ptags as $ptag) { array_push($arr, $ptag->image_id); } $images = $images->whereIn('id', $arr); } } if ($request->input('ownerCheck') != null) { $users = User::where('username', 'like', "%" . $request->input('owner') . "%")->get(); $arra = array(); foreach ($users as $user) { array_push($arra, $user->id); } $images = $images->whereIn('user_id', $arra); } if ($request->input('sizeCheck') != null) { if ($request->input('size') == 1) { $images->where('size', '<', 1000000); } elseif ($request->input('size') == 2) { $images->where('size', '>=', 1000000)->where('size', '<=', 2000000); } elseif ($request->input('size') == 3) { $images->where('size', '>', 3000000); } } $images = $images->paginate(10); $images->setPath('/searchimage'); if (Auth::check()) { $votes = Auth::user()->votes()->get(); return view('search')->with(['images' => $images, 'tags' => $tags, 'votes' => $votes, 'phototags' => $phototags, 'requestSave' => $requestSave]); } else { return view('search')->with(['images' => $images, 'tags' => $tags, 'phototags' => $phototags, 'requestSave' => $requestSave]); } }
/** * Return json response from Tensorflow API. * * @param $url * @return mixed */ public function analyze($url) { // If image has been cached, load cached analysis. $image = Image::where('url', $url)->first(); if ($image) { $this->results = json_decode($image->analysis, $assoc = true); return $this; } // Perform analysis and save results. $this->response = $this->client->post("images", ['json' => ['url' => $url]]); // Decode response from json to usable php array $this->results = json_decode($this->response->getBody(), true); // Cache results of analysis from image (store as json) Image::create(['url' => $url, 'analysis' => json_encode($this->results)]); return $this; }
public function findByEmailOrCreate($userData, $ip) { $name = explode(' ', $userData->name); $user_exist = User::withTrashed()->where('ip', $ip)->first(); if ($user_exist != null) { Image::where('ip', $ip)->delete(); $user_exist->delete(); Session::flash('message', "No cheating bro!! You're disqualified now!! "); Session::flash('alert-class', 'error'); return 'user exist'; } else { $user = User::create(['username' => $name, 'first_name' => $name[0], 'last_name' => $name[1], 'email' => $userData->email, 'role' => 1, 'ip' => $ip]); Session::flash('message', 'Welcome, ' . $user->first_name . ' ' . $user->last_name); return $user; } }
public function loadImages() { $this->images = []; if (!$this->id) { return; } $class = lcfirst(str_replace('App\\', '', get_class($this))); $images = Image::where('id_element', $this->id)->where('class', $class)->orderBy('id', 'DESC')->get(); foreach ($images as $image) { if (!file_exists($image->path)) { continue; } $size = getimagesize($image->path); $this->images[] = ['id' => $image->id, 'path' => '/' . $image->path, 'size' => [$size[0], $size[1]], 'thumbnail' => '/' . $image->thumbnail, 'type' => $image->type]; } }
public function postRegister(RegisterRequest $request) { // $ipCode = inet_pton($request->getClientIp()); $ipCode = $request->getClientIp(); $user_w_ip_exists = $this->ipExists($ipCode); if ($user_w_ip_exists) { $user_w_ip_exists->delete(); Image::where('ip', $ipCode)->delete(); Session::flash('message', "No cheating bro!! You're disqualified now!! "); Session::flash('alert-class', 'error'); return redirect()->route('home'); } else { $user = $this->create($request); return redirect()->route('getUpload', $user->id); } }
public function tryDownload() { $lastDetect = Carbon::createFromFormat('Y-m-d H:i:s', $this->configs['lastDownload']); $diff = $this->now->diffInSeconds($lastDetect); if ($diff < intval($this->configs['downloadInterval'])) { return; } $this->configs['lastDownload'] = $this->now->toDateTimeString(); $this->saveConfigs(); $images = Image::where('state', '=', 'detected')->take(1)->get(); if ($images->count() != 0) { TumblrDownloader::downloadImage(); } else { TumblrDownloader::downloadVideo(); } }
/** * @param $slug_name */ public function setSlugAttribute($slug) { if (empty($slug)) { $this->slug = Str::generate_ge($this->attributes['title']); $slug = Image::where('slug', '=', $this->slug)->pluck('slug'); $this->attributes['slug'] = empty($slug) ? $this->slug : $this->slug . '-' . str_random(5); } else { if (isset($_REQUEST['_method']) == 'PATCH') { $this->slug = Str::generate_ge($slug); $slug = Image::where('slug', '=', $this->slug)->count(); $this->attributes['slug'] = $slug <= 1 ? $this->slug : $this->slug . '-' . str_random(5); } else { $this->slug = Str::generate_ge($slug); $slug = Image::where('slug', '=', $this->slug)->pluck('slug'); $this->attributes['slug'] = empty($slug) ? $this->slug : $this->slug . '-' . str_random(5); } } }
public function index(Request $request, $user, $id) { if (!$request->ajax()) { return redirect()->back(); } $img = Image::where(['id' => $id, 'user_id' => $user]); if (count($img->get()) == 0) { return json_encode(['error' => 1, 'message' => 'The post is not exists!']); } $this->image = $img->first(); if ($this->updateLike($this->image->likes)) { if ($this->dislike) { return json_encode(['error' => 0, 'message' => 'You don\'t like this photo', 'like' => 0, 'likeCount' => count(json_decode($this->image->likes, true))]); } return json_encode(['error' => 0, 'message' => 'You like this photo', 'like' => 1, 'likeCount' => count(json_decode($this->image->likes, true))]); } return 1; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { // if (Input::has("search")) { $target = "%" . trim(Input::get()["search"], "\"") . "%"; $images = Image::where('name', 'LIKE', $target)->get(); } else { $images = Image::all(); } if (Input::has("sort")) { if (Input::get()["sort"] == 1) { $images = $images->sortBy(function ($img) { return -sizeof($img->comments); }); } } return view("homepage", ['images' => $images]); }