Пример #1
0
 public function addEvent()
 {
     $user = Auth::user();
     $event = Input::get();
     $input = 'd/m/Y H:i';
     $output = 'm/d/Y H:i';
     $start = \DateTime::createFromFormat($input, $event['start']);
     $end = \DateTime::createFromFormat($input, $event['end']);
     if ($start == $end) {
         $end->add(new \DateInterval('PT1H'));
     }
     $event['start'] = date_format($start, $output);
     $event['end'] = date_format($end, $output);
     $eobj = Events::find($event['id']);
     if ($eobj == null) {
         $e = new Events();
         $action = "add";
     } else {
         $e = $eobj;
         $action = "refresh";
     }
     $e->title = $event['title'];
     $e->type = "";
     $e->start = $start;
     $e->end = $end;
     $e->save();
     $event['id'] = $e->id;
     return response()->json(array('response' => $action, 'event' => $event));
 }
 public function delete(Request $request)
 {
     if (!ACL::hasPermission('events', 'delete')) {
         return redirect(route('events'))->withErrors(['Você não pode deletar Eventos.']);
     }
     Events::find($request->get('eventsId'))->delete();
     $success = "Evento excluído com sucesso.";
     return redirect(route('events'))->with(compact('success'));
 }
Пример #3
0
 public function deleteEvent(Request $request, $event_id)
 {
     $event = Events::find($event_id);
     $user = User::where('remember_token', $request->token)->first();
     if ($event->admin->id != $user->id) {
         return Response::json(["status" => "NOT_OK", "response" => "Event can only be deleted by event creator"], 400);
     }
     // $event->delete();
     return Response::json(["status" => "OK", "response" => "Event deleted!"], 200);
 }
Пример #4
0
 public function deleteEvent($deleteEventId)
 {
     // return('i ma deleting event');
     //$deleteEvent = Events::where('event_id', $deleteEventId)->firstOrFail();
     $deleteEvent = Events::find($deleteEventId);
     //return $deleteEvent->eventImage;
     //delete the image associative with the event
     \File::Delete('img/Event/' . $deleteEvent->eventImage);
     $deleteEvent->delete();
     return redirect('events');
 }
Пример #5
0
 public function addguest($id, Request $request)
 {
     $email = $request->input('guest_email');
     $event = Events::find($id);
     $guest = Guests::where('email', $email, 1)->first();
     if ($event && $email) {
         if (!isset($guest->id)) {
             $guest = new Guests();
             $guest->name = $request->input('guest_name');
             $guest->email = $email;
             $guest->save();
         }
         $guest_pivot = new PivotEventGuest();
         $guest_pivot->guest = $guest->id;
         $guest_pivot->event = $event->id;
         $guest_pivot->save();
     }
     return redirect()->action('EventsController@show', ['id' => $id]);
 }