/** * Update a minifig * @access public * @param int $id * @param MinifigRequest $request */ public function update($id, MinifigRequest $request) { $minifig = Minifig::find($id); $minifig->name = $request->name; $minifig->set_id = $request->set_id; $minifig->save(); if ($request->images_to_delete) { foreach ($request->images_to_delete as $id_image) { $image = Image::find($id_image); $image->delete(); } } $files = $request->file('files'); if (count($files) > 0) { foreach ($files as $file) { if ($file) { $filename = sha1(rand(1, 100000) . time()) . '.' . $file->guessExtension(); $file->move($this->uploadpath, $filename); Image::create(['minifig_id' => $id, 'filename' => $filename]); } } } $request->session()->flash('msg', 'Minifig saved'); return redirect()->action('MinifigController@index'); }
/** * 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'); }
public function updateText(Request $request) { $id = $request->get('id'); $image = Image::find($id); $image->text = $request->get('text'); $image->save(); exit; }
/** * 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]); }
public function deleteImage() { $user = Auth::User(); $userID = $user->id; $image = Image::find($_POST['imageID']); Storage::delete("{$userID}/{$image->imageName}"); Image::destroy($_POST['imageID']); return "Image Deleted!"; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $data = Image::find($id); if ($data) { return view('forone::' . $this->uri . "/edit", compact('data')); } else { return $this->redirectWithError('data not found.'); } }
public function removeClosedImages($closedImages) { foreach ($closedImages as $image) { $propertyImage = \App\Image::find($image->id); if ($propertyImage) { $propertyImage->delete(); } dispatch((new KillImageFromDisk($image->dataUri))->onQueue('killImage')); } }
/** * Handles displaying an image on a request. * * @param $hash * @return mixed * @throws \App\Exceptions\MissingImageException */ public function index($hash) { if (is_numeric($hash)) { throw new AccessDeniedException('You should not access an image by it\'s ID.'); } $hash = $this->stripExtension($hash); $id = $this->hash->decode($hash); $image = Image::find($id); return response($image->image, 200)->header('Content-Type', 'image/png'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { if (Auth::check()) { $image = Image::find($id); $image->title = $request->input('title'); $image->description = $request->input('description'); $image->item_id = $request->input('itemid'); $image->save(); return $image; } }
public function postMove() { $rules = array('new_album' => 'required|numeric|exists:albums,id', 'photo' => 'required|numeric|exists:images,id'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('index'); } $image = Image::find(Input::get('photo')); $image->album_id = Input::get('new_album'); $image->save(); return Redirect::route('show_album', array('id' => Input::get('new_album'))); }
public function apprecier($id_image, Request $request) { if (!is_numeric($id_image) || !Image::find($id_image)) { return response()->json(['response' => 'ERREUR.']); } if (Auth::user()->aime($id_image)) { DB::table('apprecie')->where(['id_utilisateur' => Auth::user()->id, 'id_image' => $id_image], false)->delete(); return response()->json(['response' => 'doitUnlike']); } else { DB::table('apprecie')->insert(['id_utilisateur' => Auth::user()->id, 'id_image' => $id_image]); return response()->json(['response' => 'doitLike']); } }
/** * Execute the console command. * * @return mixed */ public function handle() { if ($this->option('all')) { foreach (Image::all() as $image) { $image->regenerate(); } } elseif ($this->argument('image')) { $image = Image::find($this->argument('image')); if (count($image)) { $image->regenerate(); } } }
public function removeUnrelatedImages() { $skip = 0; $removeArray = []; do { $images = \App\Image::whereDoesntHave('property')->take(100)->skip($skip)->get(); foreach ($images as $imageKey => $image) { \App\Image::find($image->id)->delete(); dispatch((new KillImageFromDisk($image->dataUri))->onQueue('killImage')); $removeArray[] = $image->dataUri; } \Storage::delete($removeArray); $skip += 100; } while ($images->isEmpty() == false); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { //This id is passed by the controller that calls the request class $image = Image::find($this->id); switch ($this->method()) { case 'GET': case 'DELETE': return []; case 'POST': return ['name' => 'required|unique:images,name', 'type' => 'required', 'order' => 'numeric', 'image' => 'required|image|mimes:jpeg,bmp,png', 'link' => 'string']; case 'PUT': case 'PATCH': return ['name' => 'required|unique:images,name,' . $image->id, 'type' => 'required', 'order' => 'numeric', 'image' => 'image|mimes:jpeg,bmp,png', 'link' => 'string']; default: break; } }
public function validation(AdminRequest $request) { foreach ($request->all() as $element => $coche) { // On vérifie si l'image souhaite être envoyée ou non // En cas d'autre réponse, on ignore et l'image reste soumise à validation ;-) if (starts_with($element, 'radio')) { switch ($coche) { case 'envoi_oui': Image::find(substr($element, 5))->est_gardee(true); break; case 'envoi_non': Image::find(substr($element, 5))->est_gardee(false); break; } } } return Redirect::to('admin'); }
public function create(Request $request) { $server = new Server(); $server->hostname = $request->input('server.hostname'); $server->ip = $request->input('server.ip'); $server->status = 'on'; $server->affectRandomIpAddress(); $flavor = Flavor::find($request->input('server.flavor')); if (isset($flavor)) { $server->flavor()->associate($flavor); } $image = Image::find($request->input('server.image')); if (isset($image)) { $server->image()->associate($image); } $server->save(); sleep(10); return response()->json(['servers' => [$server->serialize()], 'images' => [$server->image->serialize()], 'flavors' => [$server->flavor->serialize()]]); }
/** * "gallery_image_ids" setter. * * @param int[] image_ids Ordered list of image ids. */ public function setGalleryImageIdsAttribute($image_ids) { // PHP array_intersect() function will change array order, so avoid it $filter = $this->image_ids; $hide_image_ids = array_diff($filter, $image_ids); $weight = count($image_ids); foreach ($image_ids as $image_id) { if (!in_array($image_id, $filter)) { continue; } $image = Image::find($image_id); $image->weight = $weight; $image->save(); $weight--; } foreach ($hide_image_ids as $image_id) { $image = Image::find($image_id); $image->weight = null; $image->save(); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { echo $request->get('front_page') . '<br/>'; $img = Image::find($id); $img->path = $request->get('path'); $img->description = $request->get('description'); $img->front_page = (int) $request->get('front_page'); $img->image_type_id = $request->get('type'); $img->save(); echo '<a href="/home/image/1/edit">edit</a>'; }
public function display($id) { // https://laracasts.com/discuss/channels/laravel/laravel-file-storage // https://laracasts.com/discuss/channels/general-discussion/storage-get-image-as-file $image = Image::find($id); if (is_object($image) && Storage::disk('images')->has($image->path)) { return response(Storage::disk('images')->get($image->path), 200)->header('Content-Type', $image->mime); } else { return response(Storage::disk('images')->get('image_not_found.png'), 200)->header('Content-Type', 'image/png'); } }
public function deleteNegocio($id) { $negocio = Negocio::find($id); $s3 = \Storage::disk('s3'); $logo_to_delete = str_replace('//s3.amazonaws.com/el-sendero-del-chaman/', '', $negocio->logo()); if ($s3->exists($logo_to_delete)) { $s3->delete($logo_to_delete); } $images = $negocio->images; foreach ($images as $image) { $s3_slices = explode('el-sendero-del-chaman/', $image->image); $image_to_delete = isset($s3_slices[1]) ? $s3_slices[1] : 'NULL.jpg'; if ($s3->exists($image_to_delete)) { $s3->delete($image_to_delete); } $negocio->images()->detach($image->id); $image = Image::find($image->id); $image->delete(); } $negocio->delete(); return back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $image = Image::find($id); $image->delete(); return redirect('/')->with('message', 'You just uploaded an image!'); }
public function avaDel($id) { $files = Image::find($id)->file_name; DB::table('image')->where('id', $id)->delete(); $dir = public_path() . '/avas/' . $files; File::delete($dir); return Redirect::to('ava'); }
public function deleteImage($id) { $image = Image::find($id); if ($image) { $image->delete(); } return response()->json(['result' => 'success']); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $image = Image::find($id); return view('image/show', compact('image')); }
public function deactivate($id) { $image = Image::find($id); $image->status = 0; $image->save(); return redirect('home/galleries'); }
/** * Get the add image form. * * @return Response */ public function getDeleteImage($id) { //Finding the image with the given id $image = Image::find($id); //Authorization check using ImagePolicy $this->authorize('destroy', $image); //Deleting the image record from the database $delete_record = $image->delete(); if ($delete_record) { //Deleting the file if record is deleted successfully $delete_file = Storage::delete($image->name); if ($delete_file) { //If file is deleted echo "Deleted"; } } else { echo "Delete failed"; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $image = Image::find($id); $filename = pathinfo($image->filename, PATHINFO_FILENAME); $fileExt = pathinfo($image->filename, PATHINFO_EXTENSION); unlink(public_path() . '/uploads/images/' . $filename . '.' . $fileExt); unlink(public_path() . '/uploads/images/' . $filename . '_640.' . $fileExt); unlink(public_path() . '/uploads/images/' . $filename . '_1280.' . $fileExt); unlink(public_path() . '/uploads/images/' . $filename . '_1920.' . $fileExt); unlink(public_path() . '/uploads/images/' . $filename . '_2560.' . $fileExt); $image->delete(); flash()->info('Image deleted successfully.'); return redirect(route('backend')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $image = Image::find($id); // Save banner $image->id = $id; $image->name = $request->input('name'); $image->user_id = 1; $image->url = $request->input('url'); $image->description = $request->input('description'); $image->save(); // Set Flash Message session()->flash('flash_message', 'Photo Updated!'); // Redirect to new banner page return redirect('admin/photos/' . $image->id . ''); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $image = Image::find($id); $id_product = $image->id_product; $image = Image::find($id); File::delete('uploads/images/original/' . $image->filename); File::delete('uploads/images/medium/' . $image->filename); File::delete('uploads/images/small/' . $image->filename); $image->delete(); if (!empty($id_product)) { return redirect('product/create/' . $id_product)->with('message', 'delete successfully'); } else { return redirect('image/upload')->with('message', 'delete successfully'); } }
/** * Remove the specified resource from storage. * * @param int $id * @param Request $request * @return Response * @throws \Exception */ public function destroy($id, Request $request) { Image::find($id)->delete(); \File::delete($request->input('image_url'), $request->input('image_thumb_url')); return \Redirect::route('admin.product.images', ['id' => $request->input('product_id')]); }