Files

39 lines
922 B
PHP

<?php
namespace App\Http\Controllers;
use App\Services\ApiService;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\Client\ConnectionException;
class DashboardController extends Controller
{
protected ApiService $api;
public function __construct(ApiService $api)
{
$this->api = $api;
}
/**
* @param ApiService $api
* @return Factory|View|Application|\Illuminate\View\View|object
* @throws ConnectionException
*/
public function index(ApiService $api)
{
$response = $api->withAuth()->get('/employee/me');
$user = $response->json();
$statsResponse = $api->withAuth()->get('/employee/statistics');
$stats = $statsResponse->json();
return view('dashboard', [
'user' => $user,
'stats' => $stats
]);
}
}