41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Dashboard\Controllers;
|
|
|
|
use App\Providers\AuthCheckProvider;
|
|
use App\Providers\InertiaProvider;
|
|
use App\Scopes\CommonController;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Js;
|
|
|
|
class DashboardController extends CommonController {
|
|
public function __invoke(Request $request) {
|
|
if ($this->checkAuth()) {
|
|
return $this->renderForLoggedInUser($request);
|
|
}
|
|
|
|
return redirect()->intended('/login');
|
|
}
|
|
|
|
private function renderForLoggedInUser(Request $request) {
|
|
$authCheckProvider = new AuthCheckProvider;
|
|
$inertiaProvider = new InertiaProvider('Dashboard/Dashboard', ['appName' => app('tenant')->name]);
|
|
return $inertiaProvider->render();
|
|
}
|
|
|
|
private function renderForGuest(Request $request) {
|
|
}
|
|
|
|
public function getMyInvoices() : JsonResponse {
|
|
$invoices = $this->invoices->getMyInvoicesWidget();
|
|
return response()->json(['myInvoices' => $invoices]);
|
|
}
|
|
|
|
public function getOpenCostUnits() : JsonResponse {
|
|
$costUnits = $this->costUnits->listForSummary(5);
|
|
return response()->json(['openCostUnits' => $costUnits]);
|
|
}
|
|
}
|