Using the app singleton key instead of repeating the same logic

parent 0ddaf7e7
...@@ -31,22 +31,12 @@ class ApplicationVersionViewComposer ...@@ -31,22 +31,12 @@ class ApplicationVersionViewComposer
public function compose(View $view) public function compose(View $view)
{ {
if ($this->onBackend() === false) { if (app('asgard.onBackend') === false) {
return; return;
} }
$view->with('version', $this->getAppVersion()); $view->with('version', $this->getAppVersion());
} }
private function onBackend()
{
$url = $this->request->url();
if (str_contains($url, config('asgard.core.core.admin-prefix'))) {
return true;
}
return false;
}
/** /**
* @return string * @return string
*/ */
......
...@@ -37,7 +37,7 @@ class AssetsViewComposer ...@@ -37,7 +37,7 @@ class AssetsViewComposer
public function compose(View $view) public function compose(View $view)
{ {
if ($this->onBackend() === false) { if (app('asgard.onBackend') === false) {
return; return;
} }
...@@ -51,14 +51,4 @@ class AssetsViewComposer ...@@ -51,14 +51,4 @@ class AssetsViewComposer
$view->with('cssFiles', $this->assetPipeline->allCss()); $view->with('cssFiles', $this->assetPipeline->allCss());
$view->with('jsFiles', $this->assetPipeline->allJs()); $view->with('jsFiles', $this->assetPipeline->allJs());
} }
private function onBackend()
{
$url = $this->request->url();
if (str_contains($url, config('asgard.core.core.admin-prefix'))) {
return true;
}
return false;
}
} }
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace Modules\Core\Providers; namespace Modules\Core\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Maatwebsite\Sidebar\SidebarManager; use Maatwebsite\Sidebar\SidebarManager;
use Modules\Core\Sidebar\AdminSidebar; use Modules\Core\Sidebar\AdminSidebar;
...@@ -10,7 +9,6 @@ use Modules\Core\Sidebar\AdminSidebar; ...@@ -10,7 +9,6 @@ use Modules\Core\Sidebar\AdminSidebar;
class SidebarServiceProvider extends ServiceProvider class SidebarServiceProvider extends ServiceProvider
{ {
protected $defer = true; protected $defer = true;
private $request;
/** /**
* Register the service provider. * Register the service provider.
...@@ -20,21 +18,10 @@ class SidebarServiceProvider extends ServiceProvider ...@@ -20,21 +18,10 @@ class SidebarServiceProvider extends ServiceProvider
{ {
} }
public function boot(SidebarManager $manager, Request $request) public function boot(SidebarManager $manager)
{ {
$this->request = $request; if ($this->app['asgard.onBackend'] === true) {
if ($this->onBackend() === true) {
$manager->register(AdminSidebar::class); $manager->register(AdminSidebar::class);
} }
} }
private function onBackend()
{
$url = $this->request->url();
if (str_contains($url, config('asgard.core.core.admin-prefix'))) {
return true;
}
return false;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment