public function postForm(ImageRequest $request, $id_campagne) { // Création de l'instance Image (entité Eloquent ORM créée pour le projet) $Image = new Image(); $Image->id_utilisateur = Auth::user()->getId(); $Image->id_campagne = $id_campagne; $Image->titre_image = $request->input('titre_image'); $Image->description_image = $request->input('description_image'); $Image->validation_image = !Campagne::find($id_campagne)->aValider(); // Création de l'objet $photo à partir de ce qu'on récupère de 'image' (Request) $photo = Input::file('image'); $filename = time() . '_' . uniqid() . '.' . $photo->getClientOriginalExtension(); $path = public_path('uploads\\' . $filename); $photo = CLImage::make($photo->getRealPath()); $exif = $photo->exif() != null && array_key_exists('GPSLongitude', $photo->exif()) ? $photo->exif() : null; $photo->save($path); // Sauvegarde de l'image et calcul de la géolocalisation si disponible $Image->geo_image = $this->get_location($exif); $Image->lien_image = $filename; $Image->save(); // Appel de la vue de redirection return Redirect('/campagne/' . $id_campagne); // return View::make('campagne', array('campagne'=> Campagne::find($id_campagne), 'images' => Image::all()->where('id_campagne', $id_campagne, false), 'message' => 'L\'image a été mise en ligne !')); }
public function deleteLibelle(Requests\ImageRequest $request, $id_image) { $text = Libelle::find($id_image)->text_libelle; Libelle::find($id_image)->text_libelle = str_replace($request->input('libelle'), '', $text); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, ImageRequest $request) { //Find the image $image = Image::find($id); $oldOrder = $image->order; $newOrder = $request->input('order'); $type = $request->input('type'); /* Laravel can not handle using the request manager the validation of the size image that exceeds the configuration of php.in */ if ($this->imageHelper->fileImageSizeExceeded($request->file('image'))) { //Set the message and the error class Session::flash('message', 'The file image can not be greater than 2MB!'); Session::flash('alert-class', 'alert-danger'); return redirect()->back(); } //Fill this image with the new form information $image->fill($request->all()); //Getting the max permitted position $maxPosition = Image::where('type', $type)->count(); //If the admin informed a greater position, set the position as the maximum one if ($image->order > $maxPosition) { $image->order = $maxPosition; $newOrder = $maxPosition; } //Setting the right order $this->imageHelper->adjustUpdateOrder($type, $oldOrder, $newOrder, $image); //Checking if there was uploaded a image if ($request->file('image') != null) { //Delete the old image image from the filesystem File::delete($image->path); //Moves and sets the new uploaded image $this->imageHelper->uploadImage($request, $image); } $image->save(); //Sending the user to the accounts page return redirect()->route('image/index'); }