コード例 #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $trip = Trip::findOrFail($request->trip_id);
     if (!$trip) {
         return redirect()->back();
     }
     return $next($request);
 }
コード例 #2
0
ファイル: HomeController.php プロジェクト: lavanchy/reiseturi
 public function bookTrip($id)
 {
     $trip = Trip::findOrFail($id);
     $user = User::find(1);
     // TODOget curent user
     if ($trip::freeSets(1)) {
         return view('registration', ['trips' => $trips], ['user' => $user]);
     }
     return view('startpage', ['trips' => $trips]);
     // TODO SRY over boocked
 }
コード例 #3
0
 public function show($id)
 {
     $trip = Trip::findOrFail($id)->first();
     return view('trajetos.show', compact('trip'));
 }
コード例 #4
0
 /**
  * gets entries, prepared for map (with content attribute) and returns them
  *
  * @param $id
  * @return string
  */
 public function getMarkers($id)
 {
     $trip = Trip::findOrFail($id);
     if ($entries = $trip->getMarkers()) {
         return $entries;
     } else {
         return 'no entries available';
     }
 }
コード例 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param $trip_id
  * @param $entry_id
  * @return Response
  * @internal param int $id
  */
 public function destroy($trip_id, $entry_id)
 {
     $trip = Trip::findOrFail($trip_id);
     $entry = TripEntry::findOrFail($entry_id);
     if (Auth::user()->id == $trip->user_id) {
         $entry->delete();
         return redirect(url('trip') . '/' . $trip_id);
     } else {
         return 'You are not authorized to delete this entry!';
     }
 }
コード例 #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param $trip_id
  * @param $entry_id
  * @param $pic_id
  * @return Response
  * @internal param int $id
  */
 public function destroy($trip_id, $entry_id, $pic_id)
 {
     $pic = Picture::findOrFail($pic_id);
     $trip = Trip::findOrFail($trip_id);
     $entry = TripEntry::findOrFail($entry_id);
     $user = Auth::user();
     if (Auth::user()->id == $trip->user_id && $trip->id == $entry->trip_id && $pic->trip_entry_id == $entry->id) {
         $pic->deleteWithImage($user->id);
         return redirect(url('trip') . '/' . $trip_id . '/entry/' . $entry->id);
     } else {
         return 'You are not authorized to delete this picture!';
     }
 }
コード例 #7
0
 public function editTrips($id)
 {
     $trip = Trip::findOrFail($id);
     $bookings = Booking::where('trip_id', $id)->get();
     $bills = Bill::where('trip_id', $id)->get();
     $billSum = Bill::where('trip_id', $id)->sum('amountCHF');
     $countPassenger = Booking::where('trip_id', $id)->sum('countPasanger');
     $income = $countPassenger * $trip->preis;
     return view('adminTripEdit', ['trip' => $trip, 'bookings' => $bookings, 'bills' => $bills, 'billSum' => $billSum, 'income' => $income]);
 }