コード例 #1
0
 /**
  * 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]);
 }
コード例 #2
0
 public function testLastsServiceCostStatistics()
 {
     $type = factory(\App\Entities\Type::class)->create(['company_id' => $this->company_id, 'entity_key' => 'entry', 'name' => 'service']);
     $date = Carbon::now()->addMonthNoOverflow();
     for ($i = 1; $i < 7; $i++) {
         $date = $date->subMonthNoOverflow();
         for ($j = 1; $j < 3; $j++) {
             factory(\App\Entities\Entry::class)->create(['company_id' => $this->company_id, 'entry_type_id' => $type->id, 'datetime_ini' => $date, 'cost' => $date->month * 1000]);
         }
     }
     $statistics = EntryRepositoryEloquent::getLastsServiceCostStatistics();
     $date = Carbon::now()->addMonthNoOverflow();
     for ($i = 1; $i < 7; $i++) {
         $date = $date->subMonthNoOverflow();
         $this->assertEquals($statistics[$date->month], $date->month * 1000 * 2);
     }
 }