コード例 #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);
 }
コード例 #2
0
 /**
  * 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
 }
コード例 #3
0
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $flyer = Flyer::locatedAt($zip, $street);
     $file = $request->file('file');
     $photo = $this->makePhoto($file);
     $flyer->savePhoto($photo);
 }
コード例 #4
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'));
 }
コード例 #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();
 }
コード例 #6
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);
 }
コード例 #7
0
 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);
 }
コード例 #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);
 }
コード例 #9
0
 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();
 }
コード例 #10
0
 /**
  * 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);
 }
コード例 #11
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}"]);
 }
コード例 #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);
 }
コード例 #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();
 }
コード例 #14
0
ファイル: FlyersController.php プロジェクト: kchimbo/flyer
 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}"]);
 }
コード例 #15
0
ファイル: FlyersController.php プロジェクト: qtheninja/flyer
 /**
  * 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();
 }
コード例 #16
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);
 }
コード例 #17
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);
 }
コード例 #18
0
ファイル: PhotosController.php プロジェクト: anjuna/spicy
 /**
  * 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();
 }
コード例 #19
0
ファイル: AuthorizesUsers.php プロジェクト: rrubiorr81/flyer
 /**
  * @param Request $request
  * @return mixed
  */
 protected function userCreatedFlyer(Request $request)
 {
     return Flyer::where(['zip' => $request->zip, 'street' => $request->street, 'user_id' => \Auth::id()])->exists();
 }
コード例 #20
0
 protected function userCreatedFlyer(Request $request)
 {
     return Flyer::where(['zip' => $request->zip, 'street' => $request->street, 'user_id' => $this->user()->id])->exists();
 }
コード例 #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();
 }
コード例 #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();
 }
コード例 #23
0
 public function index()
 {
     $flyers = Flyer::all();
     return view('flyers.index', compact('flyers'));
 }
コード例 #24
0
ファイル: FlyersController.php プロジェクト: emptyWang/flyer
 /**
  * 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'));
 }
コード例 #25
0
 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);
 }
コード例 #26
0
 /**
  * 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'));
 }
コード例 #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();
 }
コード例 #28
0
ファイル: AuthorizeUser.php プロジェクト: DevMaurice/proflyer
 public function createdFlyer(Request $request)
 {
     Flyer::where(['street' => $request->street, 'zip' => $request->zip, 'user_id' => \Auth::user()->id])->exists();
 }
コード例 #29
0
 public function addPhoto($zip, $street, AddPhotoRequest $request)
 {
     $photo = Photo::fromFile($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
 }
コード例 #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);
 }