예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param EventsRequest $request
  * @param  int $id
  * @return Response
  * @internal param $
  */
 public function update(EventsRequest $request, $id)
 {
     $event = Event::findOrFail($id);
     $event->update($request->all());
     \Flash::success('Agenda evenement aangepast');
     return redirect('admin/events');
 }
예제 #2
0
 /**
  * @param EventsRequest $request
  * @return mixed
  */
 public function store(EventsRequest $request)
 {
     if ($request->hasFile('photo')) {
         if ($request->file('photo')->isValid()) {
             $photoName = md5(Carbon::now()) . "." . $request->file('photo')->getClientOriginalExtension();
             $request->file('photo')->move(public_path('images'), $photoName);
             $photo = Photo::create(['url' => $photoName]);
             $slug = slug_for_url($request->name . ' ' . Carbon::parse($request->date)->diffForHumans());
             $request->user()->events()->create(['name' => $request->name, 'date' => $request->date, 'description' => $request->description, 'venue' => $request->venue, 'photo_id' => $photo->id, 'slug' => $slug]);
             return back()->withNotification('Event has been created!')->withType('success');
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(EventsRequest $request, $id)
 {
     //Find the event
     $event = Event::find($id);
     //Fill up with the new informations
     $event->fill($request->all());
     $event->date = new Carbon($request->input('date'));
     //If the user changed the image.
     if ($request->hasFile('image')) {
         //Delete the old member image from the filesystem
         File::delete($event->path);
         //Moves and sets the new uploaded image
         $this->imageHelper->uploadImage($request, $event);
     }
     //Save the changes
     $event->save();
     //Sending the user to the event page
     return redirect()->route('event/index');
 }