-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDashboardController.php
58 lines (49 loc) · 1.79 KB
/
DashboardController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace App\Http\Controllers;
use App\Repositories\OrderRepository;
use App\Repositories\PaymentRepository;
use App\Repositories\RestaurantRepository;
use App\Repositories\UserRepository;
use Illuminate\Http\Request;
class DashboardController extends Controller
{
/** @var OrderRepository */
private $orderRepository;
/**
* @var UserRepository
*/
private $userRepository;
/** @var RestaurantRepository */
private $restaurantRepository;
/** @var PaymentRepository */
private $paymentRepository;
public function __construct(OrderRepository $orderRepo, UserRepository $userRepo, PaymentRepository $paymentRepo, RestaurantRepository $restaurantRepo)
{
parent::__construct();
$this->orderRepository = $orderRepo;
$this->userRepository = $userRepo;
$this->restaurantRepository = $restaurantRepo;
$this->paymentRepository = $paymentRepo;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$ordersCount = $this->orderRepository->count();
$membersCount = $this->userRepository->count();
$restaurantsCount = $this->restaurantRepository->count();
$restaurants = $this->restaurantRepository->paginate();
$earning = $this->paymentRepository->all()->sum('price');
$ajaxEarningUrl = route('payments.byMonth', ['api_token' => auth()->user()->api_token]);
return view('dashboard.index')
->with("ajaxEarningUrl", $ajaxEarningUrl)
->with("ordersCount", $ordersCount)
->with("restaurantsCount", $restaurantsCount)
->with("restaurants", $restaurants)
->with("membersCount", $membersCount)
->with("earning", $earning);
}
}