コード例 #1
0
 public function composeSideBar()
 {
     view()->composer('sections.right_bar', function ($view) {
         $sideBarImages = new Image();
         $view->with('sideBarImages', $sideBarImages->getSideBarImages());
     });
 }
コード例 #2
0
ファイル: ImageController.php プロジェクト: jdeugarte/twitter
 /**
  * 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);
 }
コード例 #3
0
 /**
  * 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();
     }
 }
コード例 #4
0
 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;
 }
コード例 #5
0
ファイル: Image.php プロジェクト: deferdie/tweet
 public function storeImage($userID, $imageName, $imagePath)
 {
     $storeImg = new Image();
     $storeImg->userID = $userID;
     $storeImg->imageName = $imageName;
     $storeImg->imagePath = $imagePath;
     $storeImg->save();
 }
コード例 #6
0
ファイル: ImageController.php プロジェクト: boybin/n4backend
 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;
 }
コード例 #7
0
 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();
 }
コード例 #8
0
 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();
 }
コード例 #9
0
 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();
 }
コード例 #10
0
 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);
 }
コード例 #11
0
ファイル: DatabaseSeeder.php プロジェクト: jentleyow/megadeal
 /**
  * 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;');
 }
コード例 #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 . '/');
             }
         }
     }
 }
コード例 #13
0
 /**
  * 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');
             }
         }
     }
 }
コード例 #14
0
ファイル: Product.php プロジェクト: bausano/Ebchod
 /**
  * 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;
 }
コード例 #15
0
 /**
  * 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'));
 }
コード例 #16
0
 /**
  * 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;
     });
 }
コード例 #17
0
ファイル: ImagesController.php プロジェクト: kobeuu/bpb-sf
 /**
  * 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');
 }
コード例 #18
0
 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);
 }
コード例 #19
0
 /**
  * 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');
 }
コード例 #20
0
ファイル: PagesController.php プロジェクト: kobeuu/bpb-sf
 /**
  * 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'));
 }
コード例 #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);
 }
コード例 #22
0
 function getExample3()
 {
     $images = \App\Image::where('date_taken', '<', '2000-00-00')->get();
     foreach ($images as $image) {
         echo $image->narrative . '<br>';
     }
     dump($images);
 }
コード例 #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'));
 }
コード例 #24
0
 public function updateText(Request $request)
 {
     $id = $request->get('id');
     $image = Image::find($id);
     $image->text = $request->get('text');
     $image->save();
     exit;
 }
コード例 #25
0
 /**
  * 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);
 }
コード例 #26
0
ファイル: ImageController.php プロジェクト: pboutin/poc-panel
 public function index()
 {
     $images = [];
     foreach (Image::all() as $image) {
         $images[] = $image->serialize();
     }
     return response()->json(['images' => $images]);
 }
コード例 #27
0
 public function checkAgian()
 {
     $images = \App\Image::whereDoesntHave('property')->get();
     if ($images->isEmpty() == false) {
         $this->removeUnrelatedImages();
     }
     return;
 }
コード例 #28
0
ファイル: ImageController.php プロジェクト: mazedlx/minifig
 /**
  * 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]);
 }
コード例 #29
0
 /**
  * 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);
 }
コード例 #30
0
ファイル: Article.php プロジェクト: jbiesiada/blog
 public function kill()
 {
     $image = Image::where('model_name', '=', 'Article')->where('foreign_id', '=', $this->id)->first();
     if (!empty($image)) {
         $image->kill();
     }
     $this->delete();
 }