public function composeSideBar()
 {
     view()->composer('sections.right_bar', function ($view) {
         $sideBarImages = new Image();
         $view->with('sideBarImages', $sideBarImages->getSideBarImages());
     });
 }
Beispiel #2
0
 /**
  * Store a newly uploaded resource in storage.
  *
  * @return Response
  */
 public function store(ImageRequest $request)
 {
     $input = $request->all();
     if (Auth::user()->image != null) {
         $image = Auth::user()->image;
         $file = Input::file('image');
         $name = time() . '-' . $file->getClientOriginalName();
         $image->filePath = $name;
         $file->move(public_path() . '/images/', $name);
     } else {
         // Store records process
         $image = new Image();
         $this->validate($request, ['title' => 'required', 'image' => 'required']);
         $image->title = $request->title;
         $image->description = $request->description;
         $image->user_id = Auth::user()->id;
         if ($request->hasFile('image')) {
             $file = Input::file('image');
             $name = time() . '-' . $file->getClientOriginalName();
             $image->filePath = $name;
             $file->move(public_path() . '/images/', $name);
         }
     }
     $image->save();
     $user = Auth::user();
     return redirect('/' . $user->username);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         if (!$request->hasFile('photo')) {
             return $this->respondWithError('No photo is selected');
         }
         $file = $request->file('photo');
         // Create Eloquent object
         $image = new Image();
         $image->point_id = $request->id;
         $image->filename = $this->generate_random_string();
         $image->mime_type = $file->getClientMimeType();
         $image->base_64 = $this->convert_to_base_64($file);
         $image->created_by = Auth::user()->id;
         $image->updated_by = Auth::user()->id;
         if (!$image->save()) {
             // If creation fails
             // Return error response
             return $this->respondInternalError();
         }
         // Select latest row from DB
         $resp = $image->orderBy('id', 'DESC')->first();
         // return with Fractal
         return Fractal::item($resp, new \App\Transformers\ImageTransformer())->responseJson(200);
     } catch (Exception $e) {
         return $this->respondInternalError();
     }
 }
 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;
 }
Beispiel #5
0
 public function storeImage($userID, $imageName, $imagePath)
 {
     $storeImg = new Image();
     $storeImg->userID = $userID;
     $storeImg->imageName = $imageName;
     $storeImg->imagePath = $imagePath;
     $storeImg->save();
 }
Beispiel #6
0
 public function saveImagable()
 {
     $imageable = new Image();
     $imageable->path = $this->getPathWithFile();
     $imageable->imageable_id = $this->model_id;
     $imageable->imageable_type = $this->model_class_path;
     $imageable->r_id = $this->r_id;
     $imageable->save();
     return $imageable;
 }
 public function newPicture($fileName, $image)
 {
     $path = public_path('/images/gallery/');
     File::exists($path) or File::makeDirectory($path, 0755, true);
     $image->resize(200, 200)->save($path . $fileName);
     $picture = new Image();
     $picture->user = Auth::user()->name;
     $picture->caption = Input::get('caption');
     $picture->imagePath = 'images/gallery/' . $fileName;
     $picture->save();
 }
 public function saveAjax(Request $request)
 {
     $filename = $request->get('name') . '-' . uniqid() . '.' . $request->get('format');
     $data = $request->get('data');
     $data = file_get_contents($data);
     file_put_contents(public_path() . '/media/tmp/' . $filename, $data);
     $image = new Image();
     $image->name = $request->get('name');
     $image->user_id = \Auth::user()->id;
     $image->save();
     $image->addMedia(public_path() . '/media/tmp/' . $filename)->toMediaLibrary();
 }
 public function save(Request $request)
 {
     $data = Input::get('image');
     list($type, $data) = explode(';', $data);
     list(, $data) = explode(',', $data);
     $data = base64_decode($data);
     $now = Carbon::now()->toDateTimeString();
     $random = strval(rand());
     $path = 'uploads/' . $now . '_' . $random . '.png';
     file_put_contents($path, $data);
     $image = new Image();
     $image->path = $path;
     $image->likes = 0;
     $image->save();
 }
 public function compose(View $view)
 {
     $tags = Tag::orderBy('id', 'DESC')->get();
     $categories = Category::orderBy('id', 'DESC')->simplepaginate(7);
     $images = Image::orderBy('id', 'DESC')->paginate(4);
     $view->with('tags', $tags)->with('categories', $categories)->with('images', $images);
 }
Beispiel #11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Truncate
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     User::truncate();
     Admin::truncate();
     Customer::truncate();
     Address::truncate();
     Category::truncate();
     Product::truncate();
     Brand::truncate();
     Type::truncate();
     Image::truncate();
     DB::statement('TRUNCATE category_product;');
     Product::clearIndices();
     Product::reindex();
     //Unguard
     Model::unguard();
     //Call
     $this->call(UsersTableSeeder::class);
     $this->call(ProductsTableSeeder::class);
     //Reguard
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Beispiel #12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($type, $id)
 {
     if ($id == 'video') {
         $events = Video::all();
         return view('video.show', compact('events'));
     } elseif ($id == 'staff') {
         $events = Staff::all();
         return view('staff.show', compact('events'));
     } elseif ($id == 'gallery') {
         $events = Image::all();
         return view('gallery.show', compact('events'));
     } else {
         $event = Event::where('slug', $id)->where('type', $type)->first();
         $location = Location::where('event_id', $event->id)->first();
         $slider = EventImage::where('event_id', $event->id)->orderBy(\DB::raw('RAND()'))->take(4)->get();
         $gallery = EventImage::where('event_id', $event->id)->first();
         if ($event->type == $type) {
             if ($event->status == 1) {
                 return view($type . '.show', compact('event', 'location', 'slider', 'gallery'));
             } else {
                 return redirect('/' . $type . '/');
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user_id = Auth::User()->id;
     if (Input::file()) {
         $file_image = array('image' => Input::file('file_image'));
         $rules = array('image' => 'required');
         $validator = validator::make($file_image, $rules);
         if ($validator->fails()) {
             return redirect::to('photo')->withInput()->withErrors($validator);
         } else {
             if (Input::file('file_image')->isValid()) {
                 $path = '../public/images';
                 $extension = Input::file('file_image')->getClientOriginalExtension();
                 $fileName = rand() . '.' . $extension;
                 Input::file('file_image')->move($path, $fileName);
                 Image::create(array('user_id' => $user_id, 'path' => $fileName));
                 Session::flash('success', 'Upload successfully');
                 return Redirect::to('photo');
             } else {
                 Session::flash('error', 'uploaded file is not valid');
                 return Redirect::to('photo');
             }
         }
     }
 }
Beispiel #14
0
 /**
  * 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;
 }
 /**
  * Fungsi buat tampilan about us
  */
 public function aboutUs()
 {
     $about = About::first();
     $gallery = Image::all();
     $tipe = Type::all();
     return view('FrontEnd.aboutUs', compact('about', 'gallery', 'tipe'));
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     WorkCategory::saving(function ($workCategory) {
         if ($workCategory->position > 0) {
             return true;
         }
         $workCategory->position = WorkCategory::max('position') + 1;
         return $workCategory;
     });
     Work::saving(function ($work) {
         if ($work->position > 0) {
             return true;
         }
         $work->position = Work::max('position') + 1;
         return $work;
     });
     Image::deleted(function ($image) {
         if (file_exists($image->path)) {
             unlink($image->path);
         }
         if (file_exists($image->thumbnail)) {
             unlink($image->thumbnail);
         }
         return true;
     });
 }
Beispiel #17
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $image = Image::findOrFail($id);
     $image->delete();
     flash()->warning('Gambar telah dihapus!');
     return redirect('/dashboard/images');
 }
 public function postVote(Request $request)
 {
     if (!Auth::id()) {
         return response()->json(['message' => 'user not found'], 400);
     }
     $profile = Profile::where("id", "=", $request->input("profileId"))->first();
     if (!$profile || $profile->isActive != 1) {
         return response()->json(['message' => 'profile not found'], 400);
     }
     $image_file = $request->file('image');
     if (!$image_file) {
         return response()->json(['message' => 'resource not found'], 400);
     }
     $image = Image::create();
     $image_file->move(storage_path(), md5($image->id));
     $img = ImageIntervention::make(storage_path() . '/' . md5($image->id));
     $img->resize(1000, 1000, function ($constraint) {
         $constraint->aspectRatio();
         $constraint->upsize();
     });
     $img->save(base_path() . '/public/images/votes/' . md5($image->id) . '.jpg', 100);
     $img = ImageIntervention::make(storage_path() . '/' . md5($image->id));
     $img->fit(80, 80);
     $img->save(base_path() . '/public/images/votes/thumb_80_' . md5($image->id) . '.jpg', 100);
     $img = ImageIntervention::make(storage_path() . '/' . md5($image->id));
     $img->fit(132, 99);
     $img->save(base_path() . '/public/images/votes/thumb_132_' . md5($image->id) . '.jpg', 100);
     $vote = Vote::firstOrCreate(['user_id' => Auth::id(), 'profile_id' => $request->input("profileId")]);
     $vote->user_id = Auth::id();
     $vote->profile_id = $request->input("profileId");
     $vote->photo = md5($image->id);
     $vote->save();
     //$request->session()->push('uploaded_images', $image->id);
     return response()->json(['message' => 'created', 'path' => '/images/votes/thumb_80_' . md5($image->id) . '.jpg', 'imageId' => $request->input("imageId")], 201);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $image = Image::find($id)->get();
     #  return view("image/show",['img'=>$image]);
     return Redirect::to('/home');
 }
Beispiel #20
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $sliders = Slider::latest()->get();
     $images = Image::latest()->take(4)->get();
     $news = News::latest('published_at')->published()->take(3)->get();
     $articles = Article::latest('published_at')->published()->take(3)->get();
     return view('pages.index', compact('articles', 'news', 'images', 'sliders'));
 }
Beispiel #21
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $images = Image::all();
     $images->each(function ($images) {
         $images->article;
     });
     return view('admin.images.index')->with('images', $images);
 }
 function getExample3()
 {
     $images = \App\Image::where('date_taken', '<', '2000-00-00')->get();
     foreach ($images as $image) {
         echo $image->narrative . '<br>';
     }
     dump($images);
 }
Beispiel #23
0
 public function index()
 {
     $userCount = User::count();
     $articleCount = Article::count();
     $tagCount = Tag::count();
     $imageCount = Image::count();
     return view('admin.index', compact('userCount', 'articleCount', 'imageCount', 'tagCount'));
 }
Beispiel #24
0
 public function updateText(Request $request)
 {
     $id = $request->get('id');
     $image = Image::find($id);
     $image->text = $request->get('text');
     $image->save();
     exit;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, Redirector $redirect)
 {
     $rules = ['name' => 'required', 'path' => 'required'];
     $this->validate($request, $rules);
     //if($id != null)
     //  $image = Image::findOrFail($id);
     //else
     $image = new Image();
     $image->name = $request->input('name');
     $image->save();
     $path = 'imgs/' . $image->id . '.' . $request->file('path')->getClientOriginalExtension();
     $image->path = $path;
     $image->save();
     Storage::disk('public')->put($path, file_get_contents($request->file('path')->getRealPath()));
     return $redirect->route("imagenes.index");
     //Storage::put('file.jpg',$request);
 }
Beispiel #26
0
 public function index()
 {
     $images = [];
     foreach (Image::all() as $image) {
         $images[] = $image->serialize();
     }
     return response()->json(['images' => $images]);
 }
 public function checkAgian()
 {
     $images = \App\Image::whereDoesntHave('property')->get();
     if ($images->isEmpty() == false) {
         $this->removeUnrelatedImages();
     }
     return;
 }
Beispiel #28
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $image = Image::find($id);
     $minifig = $image->minifig;
     $image->delete();
     Session::flash('msg', 'Successfully deleted');
     return redirect()->action('MinifigController@show', ['id' => $minifig->id]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::OrderBy('id', 'DESC')->paginate(7);
     $categories = Category::orderBy('name', 'ASC')->get();
     $tags = Tag::orderBy('name', 'ASC')->get();
     $images = Image::orderBy('article_id', 'DESC')->get();
     return view('admin.index')->with('articles', $articles)->with('tags', $tags)->with('images', $images)->with('categories', $categories);
 }
Beispiel #30
0
 public function kill()
 {
     $image = Image::where('model_name', '=', 'Article')->where('foreign_id', '=', $this->id)->first();
     if (!empty($image)) {
         $image->kill();
     }
     $this->delete();
 }