Esempio n. 1
0
 /**
  * Process the form.
  *
  * @return void
  */
 public function save()
 {
     // attach the photo to the flyer
     $photo = $this->flyer->addPhoto($this->makePhoto());
     // move the photo to the image folder
     $this->file->move($photo->baseDir(), $photo->name);
     // generate a thumbnail
     $this->thumbnail->make($photo->path, $photo->thumbnail_path);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  FlyerRequest  $request
  * @return Response
  */
 public function store(FlyerRequest $request)
 {
     Flyer::create($request->all());
     flash()->success('Success!', 'Your flyer has been created');
     return redirect()->back();
     //temporary
 }
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     $file = $request->file('file');
     $photo = $this->makePhoto($file);
     $flyer->savePhoto($photo);
 }
 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'));
 }
Esempio n. 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(FlyerRequest $request)
 {
     Flyer::create($request->all());
     session()->flash('flash_message', 'Flyer successfully created');
     // flash messaging
     //return redirect()->back();
 }
 /**
  * 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);
 }
 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);
 }
Esempio n. 8
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);
 }
 public function store(FlyerRequest $request)
 {
     //persist the flyer
     Flyer::create($request->all());
     //flash messaging
     flash()->success('Success', 'Flyer was inserted with success!');
     //redirect to landing page
     return redirect()->back();
 }
 /**
  * Process the form.
  *
  * @return void
  */
 public function save()
 {
     // attach the photo to the flyer
     // we call this addPhoto() method that the Flyer model already has
     // this method save and assigns the flyer_id in the process
     // and i need a photo so maybe i can extract a method here called makePhoto()
     $photo = $this->flyer->addPhoto($this->makePhoto());
     // move the photo to the images folder
     $this->file->move($photo->baseDir(), $photo->name);
     // generate a thumbnail
     // Image::make($this->path)
     //     ->fit(200)
     //     ->save($this->thumbnail_path);
     // an easier way is to wrap this up within our own thumbnail class
     // then i could presumbably say the below and it will accept a source and a destination of where this should go
     // $this-thumbnail->make($src, $destination);
     $this->thumbnail->make($photo->path, $photo->thumbnail_path);
 }
 /**
  * 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}"]);
 }
Esempio n. 12
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);
 }
Esempio n. 13
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();
 }
Esempio n. 14
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}"]);
 }
Esempio n. 15
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\FlyerRequest  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\FlyerRequest $request)
 {
     //
     // validate form
     //$this->validate();
     //USING FlyerRequest to Validate
     // persist flyer
     Flyer::create($request->all());
     //flash messaging
     flash('Success', 'Flyer successfully created!');
     // redirect to landing page or the flyer
     return redirect()->back();
 }
 /**
  * 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);
 }
 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);
 }
Esempio n. 18
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();
 }
Esempio n. 19
0
 /**
  * @param Request $request
  * @return mixed
  */
 protected function userCreatedFlyer(Request $request)
 {
     return Flyer::where(['zip' => $request->zip, 'street' => $request->street, 'user_id' => \Auth::id()])->exists();
 }
Esempio n. 20
0
 protected function userCreatedFlyer(Request $request)
 {
     return Flyer::where(['zip' => $request->zip, 'street' => $request->street, 'user_id' => $this->user()->id])->exists();
 }
Esempio n. 21
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();
 }
Esempio n. 22
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return Flyer::where(['zip' => $this->zip, 'street' => $this->street, 'user_id' => $this->user()->id])->exists();
 }
 public function index()
 {
     $flyers = Flyer::all();
     return view('flyers.index', compact('flyers'));
 }
Esempio n. 24
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($zip, $street)
 {
     $flyer = Flyer::locateAt($zip, $street);
     // dd($flyer);
     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);
 }
 /**
  * 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'));
 }
Esempio n. 27
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return Flyer::where(['postalCode' => $this->postalCode, 'street' => $this->street, 'user_id' => $this->user()->id])->exists();
 }
Esempio n. 28
0
 public function createdFlyer(Request $request)
 {
     Flyer::where(['street' => $request->street, 'zip' => $request->zip, 'user_id' => \Auth::user()->id])->exists();
 }
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $photo = Photo::fromFile($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
Esempio n. 30
0
 /**
  * Process the form
  */
 public function save()
 {
     $photo = $this->flyer->addPhoto($this->makePhoto());
     $this->file->move($photo->baseDir(), $photo->name);
     $this->thumbnail->make($photo->path, $photo->thumbnail_path);
 }