34 lines
769 B
PHP
Executable File
34 lines
769 B
PHP
Executable File
<?php
|
|
|
|
namespace Modules\Company\Providers;
|
|
|
|
use Kernel\Application;
|
|
use Kernel\View;
|
|
use Modules\Company\Models\Company;
|
|
use Modules\Company\Middleware\CompanyMiddleware;
|
|
|
|
class CompanyServiceProvider
|
|
{
|
|
public function register()
|
|
{
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
$app = Application::getInstance();
|
|
$app->addProtectedMiddleware(new CompanyMiddleware());
|
|
|
|
try {
|
|
if (class_exists(Company::class)) {
|
|
$mainCompany = Company::find(1);
|
|
if ($mainCompany) {
|
|
$view = new View();
|
|
$view->getEngine()->addGlobal('main_company', $mainCompany);
|
|
}
|
|
}
|
|
} catch (\Exception $e) {
|
|
// Silently fail
|
|
}
|
|
}
|
|
}
|