app/Http/Controllers/Admin/SaleController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        if(Auth::user()->companyProfile->count() == 0)
            return redirect()->route('admin.profile')->withErrors(['error' => 'Provide company profile first']);
        $sales = Sale::join('bookings', 'booking_id', 'bookings.id')
            ->join('rides', 'bookings.ride_id', 'rides.id')
            ->join('users', 'bookings.passenger_id', 'users.id')
            ->where('rides.company_id', Auth::user()->company()->id);
        if(request('date')){
            $date = [
                '0' => Carbon::createFromFormat('Y-m-d', request('date'))->startOfDay(),
                '1' => Carbon::createFromFormat('Y-m-d', request('date'))->endOfDay(),
            ];
            $sales->whereBetween('sales.created_at', $date);
        }
        $sales = $sales->get();
        return view('admin.sales.index', compact('sales'));
    }
public function index ( ) { if ( Auth :: user ( ) -> companyProfile -> count ( ) == 0 ) return redirect ( ) -> route ( 'admin.profile' ) -> withErrors ( [ 'error' => 'Provide company profile first' ] ) ; $ sales = Sale :: join ( 'bookings' , 'booking_id' , 'bookings.id' ) -> join ( 'rides' , 'bookings.ride_id' , 'rides.id' ) -> join ( 'users' , 'bookings.passenger_id' , 'users.id' ) -> where ( 'rides.company_id' , Auth :: user ( ) -> company ( ) -> id ) ; if ( request ( 'date' ) ) { $ date = [ '0' => Carbon :: createFromFormat ( 'Y-m-d' , request ( 'date' ) ) -> startOfDay ( ) , '1' => Carbon :: createFromFormat ( 'Y-m-d' , request ( 'date' ) ) -> endOfDay ( ) , ] ; $ sales -> whereBetween ( 'sales.created_at' , $ date ) ; } $ sales = $ sales -> get ( ) ; return view ( 'admin.sales.index' , compact ( 'sales' ) ) ; }
Display a listing of the resource.
Display a listing of the resource .
//