Ejemplo n.º 1
0
 public function about()
 {
     $title = trans('default.about');
     $societies = Society::orderBy('position', 'asc')->get();
     $timelines = Timeline::all();
     return view('pages.about', compact('title', 'societies', 'timelines'));
 }
Ejemplo n.º 2
0
 /**
  * Edit timeline /
  */
 public function editTimeline($timeline_id, Request $request)
 {
     $timeline = \App\Timeline::where('id', '=', $timeline_id)->first();
     $timeline_events = $timeline->event()->orderBy('start_date')->get();
     if ($request->input('showForm') == 'true') {
         return view('timelines.editTimeline')->with('showForm', 'true')->with('timeline', $timeline)->with('timeline_events', $timeline_events);
     } else {
         // Else submit form
         // Validate the request data
         $this->validate($request, ['name' => 'required']);
         $user = \Auth::user();
         $timeline->name = $request->input('name');
         $timeline->description = $request->input('description');
         $timeline->last_modified_by = $user->id;
         $timeline->save();
         // Delete events
         for ($e = 0; $e < count($timeline_events); $e++) {
             if ($request->input('delete_event' . $e) == 'true') {
                 \DB::table('character_event')->where('event_id', '=', $timeline_events[$e]->id)->delete();
                 \DB::table('event_location')->where('event_id', '=', $timeline_events[$e]->id)->delete();
                 $event = \App\Event::where('id', '=', $timeline_events[$e]->id)->first();
                 if ($event) {
                     $event->delete();
                 }
             }
         }
         // Return success message
         return view('timelines.editTimeline')->with('showForm', 'false')->with('timeline', $timeline);
     }
 }
Ejemplo n.º 3
0
 /**
  * Responds to requests to GET /
  */
 public function showHome()
 {
     $timelines = \App\Timeline::all();
     $users_timelines = null;
     if (\Auth::check()) {
         $user = \Auth::user();
         $users_timelines = \App\Timeline::where('user_id', '=', $user->id)->get();
     }
     return view('root.showHome')->with('timelines', $timelines)->with('users_timelines', $users_timelines);
 }
Ejemplo n.º 4
0
 /**
  * Edit Location /
  */
 public function editLocation($timeline_id, $location_id, Request $request)
 {
     $timeline = \App\Timeline::where('id', '=', $timeline_id)->first();
     $location = \App\Location::where('id', '=', $location_id)->first();
     if ($location) {
         if ($request->input('showForm') == 'true') {
             return view('locations.editLocation')->with('showForm', 'true')->with('location', $location)->with('timeline', $timeline);
         } else {
             // Validate the request data
             $this->validate($request, ['name' => 'required']);
             $user = \Auth::user();
             $location->name = $request->input('name');
             $location->description = $request->input('description');
             $location->last_modified_by = $user->id;
             $location->save();
             return view('locations.editLocation')->with('showForm', 'false')->with('location', $location)->with('timeline', $timeline);
         }
     } else {
         return "Update failed. Location does not exist.";
     }
 }
Ejemplo n.º 5
0
 /**
  * Edit character /
  */
 public function editCharacter($timeline_id, $character_id, Request $request)
 {
     $timeline = \App\Timeline::where('id', '=', $timeline_id)->first();
     $character = \App\Character::where('id', '=', $character_id)->first();
     if ($character) {
         if ($request->input('showForm') == 'true') {
             return view('characters.editCharacter')->with('showForm', 'true')->with('character', $character)->with('timeline', $timeline);
         } else {
             // Validate the request data
             $this->validate($request, ['name' => 'required']);
             $user = \Auth::user();
             $character->name = $request->input('name');
             $character->race = $request->input('race');
             $character->biography = $request->input('biography');
             $character->last_modified_by = $user->id;
             $character->save();
             return view('characters.editCharacter')->with('showForm', 'false')->with('character', $character)->with('timeline', $timeline);
         }
     } else {
         return "Update failed. Character does not exist.";
     }
 }
Ejemplo n.º 6
0
 public function apropos()
 {
     $timelines = Timeline::all();
     return view('pages/apropos', ['timelines' => $timelines]);
 }
Ejemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $timeline = Timeline::find($id);
     $timeline->delete();
     $timelines = Timeline::all();
     return view('timeline/liste', ['timelines' => $timelines]);
 }
Ejemplo n.º 8
0
 /**
  * Edit Location /
  */
 public function editEvent($timeline_id, $event_id, Request $request)
 {
     // Try to get event
     $event = \App\Event::where('id', '=', $event_id)->first();
     // If event exists, continue
     if ($event) {
         $timeline = \App\Timeline::where('id', '=', $timeline_id)->first();
         $event_characters = array();
         foreach ($event->characters as $character) {
             $event_characters[] = $character;
         }
         $event_locations = array();
         foreach ($event->locations as $location) {
             $event_locations[] = $location;
         }
         $characters = \App\Character::where('timeline_id', '=', $timeline_id)->orderBy('name')->get();
         $locations = \App\Location::where('timeline_id', '=', $timeline_id)->orderBy('name')->get();
         // If form has not been submitted, show form
         if ($request->input('showForm') == 'true') {
             return view('events.editEvent')->with('showForm', 'true')->with('event', $event)->with('event_characters', $event_characters)->with('event_locations', $event_locations)->with('characters', $characters)->with('locations', $locations)->with('timeline', $timeline);
         } else {
             // Else submit form
             // Validate the request data
             $this->validate($request, ['name' => 'required', 'start_date' => 'required|date_format:Y#m#d', 'end_date' => 'required|date_format:Y#m#d']);
             $user = \Auth::user();
             $event->name = $request->input('name');
             $event->start_date = $request->input('start_date');
             $event->end_date = $request->input('end_date');
             $event->description = $request->input('description');
             $event->last_modified_by = $user->id;
             $event->save();
             // Edit existing locations
             for ($l = 0; $l < count($event_locations); $l++) {
                 $location = \DB::table('event_location')->where('location_id', '=', $request->input('location_id' . $l))->where('event_id', '=', $event_id)->first();
                 if ($location) {
                     if ($request->input('location' . $l) == '--Delete Location--') {
                         \DB::table('event_location')->where('location_id', '=', $request->input('location_id' . $l))->where('event_id', '=', $event_id)->delete();
                     } else {
                         $location_name = \App\Location::where('name', '=', $request->input('location' . $l))->first();
                         \DB::table('event_location')->where('location_id', '=', $request->input('location_id' . $l))->where('event_id', '=', $event_id)->update(['location_id' => $location_name->id]);
                     }
                 }
             }
             // Add new location to database
             $location_input = $request->input('location_new');
             if ($location_input != 'Choose a Location') {
                 $location = \App\Location::where('name', 'LIKE', $location_input)->first();
                 $event->locations()->save($location);
             }
             // Edit existing characters
             for ($c = 0; $c < count($event_characters); $c++) {
                 $character = \DB::table('character_event')->where('character_id', '=', $request->input('character_id' . $c))->where('event_id', '=', $event_id)->first();
                 if ($character) {
                     if ($request->input('character' . $c) == '--Delete Character--') {
                         \DB::table('character_event')->where('character_id', '=', $request->input('character_id' . $c))->where('event_id', '=', $event_id)->delete();
                     } else {
                         $character_name = \App\Character::where('name', '=', $request->input('character' . $c))->first();
                         \DB::table('character_event')->where('character_id', '=', $request->input('character_id' . $c))->where('event_id', '=', $event_id)->update(['character_id' => $character_name->id]);
                     }
                 }
             }
             // Add new character to database
             $character_input = $request->input('character_new');
             if ($character_input != 'Choose a Character') {
                 $character = \App\Character::where('name', 'LIKE', $character_input)->first();
                 $event->characters()->save($character);
             }
             // Return success message
             return view('events.editEvent')->with('showForm', 'false')->with('event', $event)->with('timeline', $timeline);
         }
     } else {
         // Else fail
         return "Update failed. Event does not exist.";
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param CustomRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(CustomRequest $request, $id)
 {
     $timeline = Timeline::findOrFail($id);
     $timeline->update($request->all());
     return redirect(route('admin.timelines.index'))->with('success', 'L\'entrée a bien été modifiée');
 }