/** * Display a listing of the resource. * * @return Response */ public function index(VehicleRepositoryEloquent $vehicleRepo, EntryRepositoryEloquent $entryRepo, TripRepositoryEloquent $tripRepo) { $vehiclesStatistics = $vehicleRepo->getVehiclesStatistics(); $vehiclesLastPlace = $vehicleRepo->getVehiclesLastPlace(); $lastsServiceCost = $entryRepo->getLastsServiceCostStatistics(); $servicesStatistics = $entryRepo->getServicesStatistics(); $tripsStatistics = $tripRepo->getTripsStatistics(); $lastsFuelCost = $tripRepo->getLastsFuelCostStatistics(); return View::make('welcome', ['vehiclesStatistics' => $vehiclesStatistics, 'vehiclesLastPlace' => $vehiclesLastPlace, 'lastsServiceCostStatistics' => $lastsServiceCost, 'servicesStatistics' => $servicesStatistics, 'tripsStatistics' => $tripsStatistics, 'lastsFuelCostStatistics' => $lastsFuelCost]); }
public function testLastsFuelCostStatistics() { $date = Carbon::now()->addMonthNoOverflow(); for ($i = 1; $i < 7; $i++) { $date = $date->subMonthNoOverflow(); for ($j = 1; $j < 3; $j++) { factory(\App\Entities\Trip::class)->create(['company_id' => $this->company_id, 'pickup_date' => $date, 'fuel_cost' => $date->month * 1000]); } } $statistics = TripRepositoryEloquent::getLastsFuelCostStatistics(); $date = Carbon::now()->addMonthNoOverflow(); for ($i = 1; $i < 7; $i++) { $date = $date->subMonthNoOverflow(); $this->assertEquals($statistics[$date->month], $date->month * 1000 * 2); } }