Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
russsiq committed Jul 2, 2021
1 parent 319bfe9 commit 2e7df3d
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
namespace App\Http\Controllers;

use App\Contracts\BixBiteContract;
use Illuminate\Config\Repository as ConfigRepository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory as ViewFactoryContract;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class DashboardController extends Controller
Expand All @@ -16,20 +20,50 @@ class DashboardController extends Controller
*/
public function __invoke(
Application $app,
BixBiteContract $bixbite
) {
$app->view->addLocation(
BixBiteContract $bixbite,
ConfigRepository $config,
Request $request,
ViewFactoryContract $view,
): View {
$view->addLocation(
$bixbite->dashboardViewsPath()
);

return $app->view->make('dashboard', [
// 'scriptVariables' => [
// 'api_url' => $app->url->to(JsonApi::API_URL),
// 'app_name' => $app->config->get('app.name'),
// 'app_url' => $app->url->route('home'),
return $view->make('dashboard', [
'scriptVariables' => [
'page_language' => str_replace('_', '-', $app->getLocale()),
'app_name' => $config->get('app.name'),
'app_locale' => $app->getLocale(),
// 'locale' => $bixbite->locale(),
'app_url' => setting('system.app_url', url()->to('/')),
'api_url' => url()->to('/api/v1'),
// 'dashboard_base_url' => 'dashboard',
// 'locale' => $bixbite->locale(),
// ],
],
]);
}

/**
* Get the variables for vue.js or another javascript.
*
* @return string
*/
public function scriptVariables()
{
$data = json_encode([
'locale' => $this->get('locale'),
'csrf_token' => $this->get('csrf_token'),
'app_name' => $this->get('app_name'),
'app_dashboard' => $this->get('app_dashboard'),
'app_theme' => $this->get('app_theme'),
'app_url' => $this->get('app_url'),
'api_url' => $this->get('api_url'),
'dashboard' => $this->get('dashboard'),
]);

if (JSON_ERROR_NONE !== json_last_error()) {
throw new RuntimeException(json_last_error_msg());
}

return $data;
}
}

0 comments on commit 2e7df3d

Please sign in to comment.