Ejemplo n.º 1
0
 /**
  * Apply a photo to the referenced flyer.
  * Uses a dedicated form request called AddPhotoRequest.
  *
  * @param string $zip
  * @param string $street
  * @param AddPhotoRequest $request
  */
 public function store($zip, $street, AddPhotoRequest $request)
 {
     // find our flyer
     $flyer = Flyer::locatedAt($zip, $street);
     // store the photo which will be just the UploadedFile instance
     $photo = $request->file('photo');
     // we'll have a dedicated class like AddPhotoToFlyer and it will accept the flyer and the photo upload
     // and if that's its own instance, then we need to new it up and call a save method on it
     // this is an alternative way to do this.
     // if we wanted to treat this as a form object, you could even do your validation within that class rather than here, but in this case its so easy im just going to leave it in
     // and you would no longer need the AddPhotoRequest here.
     // we need to create this. we'll put it in app/Forms/AddPhotoToFlyer
     // we put this in Forms because we are treating this as a forms object
     // or i might have a more dedicated namespace like app/Flyers/AddPhotoToFlyer
     // or if you want you could put it in app/AddPhotoToFlyer and that would be okay too. thats what we will do here.
     (new AddPhotoToFlyer($flyer, $photo))->save();
     // i like using a named constructor. that way i can new up a photo and pass in the columns essentially
     // or if i wanted to fetch these from (in this case) a file's request then its useful to use a named constructor.
     // we'll pass in the photo uploaded file.
     // built up our photo
     // $photo = Photo::fromFile($request->file('photo'))->upload();
     //$photo = Photo::fromFile($request->file('photo'));
     // then we pass the photo to our flyer
     // But what about the process where we upload the file to the proper directory?
     // yes we persist it in the database. but we also need to move it to the folder and create the thumbnail.
     // located the current flyer. associate it with this flyer and save it.
     //Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 2
0
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     $file = $request->file('file');
     $photo = $this->makePhoto($file);
     $flyer->savePhoto($photo);
 }
Ejemplo n.º 3
0
 public function addPhoto($zip, $street, Request $request)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']);
     $photo = Photo::fromForm($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
     //return view('flyers.show',compact('flyer'));
 }
 public function store($zip, $street, AddPhotoRequest $request)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     $photo = $request->file('photo');
     (new AddPhotoToFlyer($flyer, $photo))->save();
     //$photo = Photo::fromFile($request->file('photo'));
     //Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 5
0
 public function addPhoto($zip, $street, ChangeFlyerRequest $request)
 {
     if (!$this->userCreatedFlyer($request)) {
         return $this->unauthorized($request);
     }
     $photo = $this->makePhoto($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 6
0
 /**
  * Store a new foto.
  *
  * @return \Illuminate\Http\Response
  */
 public function store($zip, $street, Request $request)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     return Response::json($request->file(), 200);
     $photo = $request->file('file');
     $name = $photo->fileName();
     //$photo = Photo::fromFile($request->file('file'))->upload();
     $flyer->photos()->create(['path' => "/flyers/photos/{$name}"]);
 }
Ejemplo n.º 7
0
 public function addPhoto($zip, $street, Request $request)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']);
     if (!$this->userCreatedFlyer($request)) {
         return $this->unauthorized($request);
     }
     $photo = $this->makePhoto($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 8
0
 public function store(Request $request, $zip, $street)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png, bmp']);
     if (!$this->userCreatedFlyer($request)) {
         return $this->unauthorized($request);
     }
     $flyer = Flyer::locatedAt($zip, $street);
     $photo = $request->file('photo');
     (new AddPhotoToFlyer($flyer, $photo))->save();
 }
Ejemplo n.º 9
0
 public function addPhotos($zip, $street, Request $request)
 {
     $this->validate($request, ['photo' => 'mimes:jpg,jpeg,png,bmp']);
     //$file = $request->file('photo'); // paramName
     //$file->move('flyers/photos', $name);
     //$flyer = Flyer::locatedAt($zip, $street)->first();
     $photo = $this->makePhoto($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
     //$flyer->photos()->create(['path' => "flyers/photos/{$name}"]);
 }
Ejemplo n.º 10
0
 /**
  * Apply a photo to the referenced flyer.
  * @param string  $zip  
  * @param string  $street  
  * @param Request $request 
  */
 public function addPhoto($zip, $street, Request $request)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']);
     $flyer = Flyer::locatedAt($zip, $street);
     if ($flyer->user_id !== \Auth::id()) {
         if ($request->ajax()) {
             return response(['message' => 'nowayjose'], 403);
         }
         flash('nowayjose');
         redirect('/');
     }
     $photo = $this->makePhoto($request->file('photo'));
     $flyer->addPhoto($photo);
 }
Ejemplo n.º 11
0
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $photo = Photo::fromFile($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
     //        $this->validate($request,[
     //            'photo' => 'required|mimes:jpg,jpeg,png,bmp'
     //        ]);
     //
     //
     //        if(! $this->userCreatedFlyer($request))
     //        {
     //          return $this->unauthorized($request);
     //        }
     //        $photo = $this->makePhoto($request->file('photo'));
     //
     //        Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     /*
     This was a way of validating it using a trait, where the two methods here were defined. 
      
     if (!$this->userCreatedFlyer($request)) {
         return $this->unauthorized($request);
     }
     */
     /* Out with the old...
             $photo = Photo::fromFile($request->file('photo'));
     
             Flyer::locatedAt($request->zip,$request->street)->addPhoto($photo);
             */
     $flyer = Flyer::locatedAt($request->zip, $request->street);
     $photo = $request->file('photo');
     (new AddPhotoToFlyer($flyer, $photo))->save();
 }
Ejemplo n.º 13
0
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $photo = Photo::fromFile($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 14
0
 /**
  * Apply a photo to the referenced flyer
  * @param $zip
  * @param $street
  * @param AddPhotoRequest $request
  */
 public function store($zip, $street, AddPhotoRequest $request)
 {
     $photo = Photo::fromFile($request->file('file'));
     //$photo = $this->makePhoto($request->file('file'));
     Flyer::locatedAt($zip, $street)->addPhotos($photo);
 }
Ejemplo n.º 15
0
 public function show($zip, $street)
 {
     $street = str_replace('-', ' ', $street);
     return Flyer::locatedAt($zip, $street)->first();
     //return Flyer::where(compact('zip', 'street'))->first();
 }
Ejemplo n.º 16
0
 /**
  * Add photo to the referenced flyer. This is triggered when User drops photo
  * in the Dropzone location.
  * @param $zip
  * @param $street
  * @param Request $request
  */
 public function addPhoto($zip, $street, Request $request)
 {
     //confirmtion that the photo file will be in appropriate format types
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']);
     // if user didn't create the flyer, return with unathorized request
     if (!$this->userCreatedFlyer($request)) {
         return $this->unathorized($request);
     }
     //build up our photo instance taking the file from dropzone plugin
     $photo = $this->makePhoto($request->file('photo'));
     //Save photo and associate it with the Flyer
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 17
0
 public function addPhoto(Request $request, $zip, $street)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,bmp,png']);
     Flyer::locatedAt($zip, $street)->addPhoto(FlyerPhoto::fromForm($request));
 }
Ejemplo n.º 18
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($zip, $street)
 {
     $flyer = Flyer::locatedAt($zip, $street)->first();
     return view('flyers.show')->with(['flyer' => $flyer]);
 }
Ejemplo n.º 19
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($zip, $street)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     return view('flyers.show', compact('flyer'));
 }
Ejemplo n.º 20
0
 /**
  * Apply a photo to the referenced flyer...
  * @param $zip
  * @param $street
  * @param ChaneFlyerRequest $request
  */
 public function addPhotos($zip, $street, ChaneFlyerRequest $request)
 {
     $photo = $this->makePhoto($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 21
0
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     $photo = $request->file('photo');
     (new AddPhotoToFlyer($flyer, $photo))->save();
 }
 /**
  * Display the specified resource.
  *
  * @param $zip
  * @param $street
  * @return \Illuminate\Http\Response
  * @internal param int $id
  */
 public function show($zip, $street)
 {
     //works
     $flyer = Cache::remember('rightflyer', 1, function () use($zip, $street) {
         return Flyer::locatedAt($zip, $street);
     });
     return view('flyers.show', compact('flyer'));
 }
Ejemplo n.º 23
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($zip, $street)
 {
     // grabs the first address with a zip of this and street of that
     $flyer = Flyer::locatedAt($zip, $street);
     return view('flyers.show', compact('flyer'));
 }
 public function addPhoto($zip, $street, Request $request)
 {
     $this->validate($request, ['photo' => 'required|mimes: jpg,jpeg,png,bmp']);
     $photo = $this->makePhoto($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Ejemplo n.º 25
0
 /**
  * Add photo to a flyer
  * 
  * @param String  $zip     
  * @param String  $street  
  * @param Request $request 
  */
 public function store($zip, $street, CreateFlyerPhotoRequest $request)
 {
     $file = $request->file('photo');
     $flyer = Flyer::locatedAt($zip, $street);
     (new AddPhotoToFlyer($file, $flyer))->save();
 }
Ejemplo n.º 26
0
 /**
  *Add a photo to flyer
  *
  * @param $postalCode
  * @param $street
  * @param AddPhotoRequest $request
  */
 public function store($postalCode, $street, AddPhotoRequest $request)
 {
     $flyer = Flyer::locatedAt($postalCode, $street);
     $photo = $request->file('photo');
     (new AddPhotoToFlyer($flyer, $photo))->save();
 }
Ejemplo n.º 27
0
 /**
  * Display the specified resource.
  *
  * @param $zip
  * @param $street
  * @return \Illuminate\Http\Response
  */
 public function show($zip, $street)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     return view('flyers.show')->with('flyer', $flyer);
 }