Esempio n. 1
0
 public function postForm(MediaRequest $request, MediaGestionInterface $mediaGestion)
 {
     if ($mediaGestion->save($request->file('image'))) {
         return view('photo_ok');
     }
     return redirect('photo/form')->with('error', 'Votre image ne peut pas être envoyée !');
 }
Esempio n. 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(MediaRequest $request, $id)
 {
     $media = Media::findOrFail($id);
     $input = $request->all();
     $media->update($input);
     return redirect('media');
 }
Esempio n. 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(MediaRequest $request, Media $media)
 {
     $this->authorize('update', $media);
     $type_id = $this->checkType($request->input('type_id'));
     if (!$type_id) {
         \Flash::error('Invalid type. Please enter in a text name.');
         return redirect()->back();
     }
     $request['type_id'] = $type_id;
     $media->update($request->all());
     \Flash::success('Media successfully updated');
     return redirect('media');
 }
Esempio n. 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(MediaRequest $request)
 {
     $fileExte = $request->file('file')->getClientOriginalExtension();
     $fileName = time() . "." . $fileExte;
     $media = new Media();
     $media->mediaName = $fileName;
     $media->mediaType = $fileExte;
     $media->mediaCaption = $request->get('caption');
     if ($media->save()) {
         $upload = $request->file('file')->move("uploads/", $fileName);
         return redirect('media')->with('message', 'Image uploaded.');
     } else {
         return redirect('media')->with('error', 'Something went wrong.');
     }
 }