|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Modules\ArmaLife\Http\Controllers; |
| 4 | + |
| 5 | +use Illuminate\Http\Request; |
| 6 | + |
| 7 | +use App\Http\Requests; |
| 8 | +use App\Http\Controllers\Controller; |
| 9 | +use App\Modules\ArmaLife\Repositories\Eloquent\PlayerRepository; |
| 10 | +use App\Modules\ArmaLife\Repositories\Eloquent\VehicleRepository; |
| 11 | +use App\Modules\ArmaLife\Repositories\Eloquent\HouseRepository; |
| 12 | + |
| 13 | + |
| 14 | +class ArmaLifeController extends Controller |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @var PlayerRepository |
| 18 | + */ |
| 19 | + protected $playerRepository; |
| 20 | + |
| 21 | + /** |
| 22 | + * @var VehicleRepository |
| 23 | + */ |
| 24 | + protected $vehicleRepository; |
| 25 | + |
| 26 | + /** |
| 27 | + * @var HouseRepository |
| 28 | + */ |
| 29 | + protected $houseRepository; |
| 30 | + |
| 31 | + public function __construct(PlayerRepository $playerRepository, VehicleRepository $vehicleRepository, HouseRepository $houseRepository) |
| 32 | + { |
| 33 | + $this->playerRepository = $playerRepository; |
| 34 | + $this->vehicleRepository = $vehicleRepository; |
| 35 | + $this->houseRepository = $houseRepository; |
| 36 | + } |
| 37 | + |
| 38 | + public function dashboard() |
| 39 | + { |
| 40 | + $cash = (int) $this->playerRepository->cash(); |
| 41 | + $bank = (int) $this->playerRepository->bank(); |
| 42 | + $total = $cash + $bank; |
| 43 | + |
| 44 | + return [ |
| 45 | + 'data' => [ |
| 46 | + 'cash' => $cash, |
| 47 | + 'bank' => $bank, |
| 48 | + 'total' => $total, |
| 49 | + 'vehicles' => $this->vehicleRepository->count(), |
| 50 | + 'houses' => $this->houseRepository->count(), |
| 51 | + 'players' => $this->playerRepository->count(), |
| 52 | + 'newest' => $this->playerRepository->newest(), |
| 53 | + 'cops' => $this->playerRepository->cops(), |
| 54 | + 'medics' => $this->playerRepository->medics(), |
| 55 | + 'admins' => $this->playerRepository->admins(), |
| 56 | + 'donators' => $this->playerRepository->donators() |
| 57 | + ] |
| 58 | + ]; |
| 59 | + } |
| 60 | +} |
0 commit comments