public function single($slug) { $start = Carbon::today()->startOfDay(); $end = Carbon::today()->endOfDay(); $company = TravelCompany::where('slug', $slug)->first(); $bookings = Payment::where('travel_company_id', $company->id)->whereBetween('updated_at', [$start, $end])->orderBy('updated_at', 'asc')->get(); // dd($bookings); return view('admin.accounting.single', ['bookings' => $bookings]); }
public function index() { $totalTrips = Trip::all()->count(); $totalTravelCompanies = TravelCompany::all()->count(); $totalUsers = User::all()->count(); $totalPaidBookings = Booking::where('status', 'paid')->count(); $totalBus = Rental::all()->count(); return view('admin.dashboard', ['tT' => $totalTrips, 'tU' => $totalUsers, 'tP' => $totalPaidBookings, 'tC' => $totalTravelCompanies, 'tB' => $totalBus]); }
/** * @param Request $request * * @return \Illuminate\Http\RedirectResponse */ public function profile_update(Request $request) { $travel_company = TravelCompany::find(Auth::travel_company_staff()->get()->travel_company->id); // dd($request->all()); $this->validate($request, ['facebook_link' => 'url', 'description' => 'min:30|max:200', 'bus_features' => 'required', 'name' => 'required', 'country' => 'required', 'city' => 'required', 'region' => 'required']); $input = $request->except(['password', 'c_password', 'confirm_password', 'bus_features']); $travel_company->update($input); $bus_features = $request->bus_features; $travel_company->bus_features()->attach($bus_features); return redirect()->route('company_settings'); }
/** * @param Request $request * * @return $this */ public function search(Request $request) { $this->validate($request, ['departure_station' => 'required|different:destination_station', 'destination_station' => 'required', 'start' => 'required']); $travel_companies = TravelCompany::all(); $to = $request->destination_station; $from = $request->departure_station; $departure_date = Carbon::parse($request->start); $dd_start = Carbon::parse($request->start)->startOfDay(); $dd_end = Carbon::parse($request->start)->endOfDay(); // $trips = Trip::all(); // dd($request->all(), $trips); if ($departure_date->lt(Carbon::today())) { return redirect()->back()->withErrors('Invalid Date'); } else { if ($departure_date->eq(Carbon::today())) { $trips = $this->getTodayOneWayTrips($from, $to); // dd($trips); } else { // $trips = Trip::whereraw('departure_date = ? AND departure_station = ? AND destination_station = ?', // [$departure_date, $from, $to])->get(); $trips = Trip::whereraw('departure_station = ? AND destination_station = ?', [$from, $to])->whereBetween('departure_date', [$dd_start, $dd_end])->get(); } } return view('pages.all_trips', ['travel_companies' => $travel_companies, 'from' => $from, 'to' => $to, 'start' => $departure_date])->with('trips', $trips); }
/** * @param $start * @param $end * @param $model * * @return mixed */ private function getQueryData($start, $end, $model) { if ($model == "Payment") { $data = Payment::whereBetween('created_at', [$start, $end])->orderBy('created_at', 'desc')->get(); } elseif ($model == "TravelCompany") { $data = TravelCompany::whereBetween('created_at', [$start, $end])->orderBy('created_at', 'desc')->get(); } elseif ($model == "User") { $data = User::whereBetween('created_at', [$start, $end])->orderBy('created_at', 'desc')->get(); } return $data; }
/** * Remove the specified resource from storage. * * @param TravelCompany $travelCompany * * @throws \Exception * @internal param int $id * @return Response */ public function destroy(TravelCompany $travelCompany) { $travelCompany->delete(); return redirect()->route('admin.travel-companies.index'); }