Using the app singleton key instead of repeating the same logic

parent 0ddaf7e7
......@@ -31,22 +31,12 @@ class ApplicationVersionViewComposer
public function compose(View $view)
{
if ($this->onBackend() === false) {
if (app('asgard.onBackend') === false) {
return;
}
$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
*/
......
......@@ -37,7 +37,7 @@ class AssetsViewComposer
public function compose(View $view)
{
if ($this->onBackend() === false) {
if (app('asgard.onBackend') === false) {
return;
}
......@@ -51,14 +51,4 @@ class AssetsViewComposer
$view->with('cssFiles', $this->assetPipeline->allCss());
$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 @@
namespace Modules\Core\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
use Maatwebsite\Sidebar\SidebarManager;
use Modules\Core\Sidebar\AdminSidebar;
......@@ -10,7 +9,6 @@ use Modules\Core\Sidebar\AdminSidebar;
class SidebarServiceProvider extends ServiceProvider
{
protected $defer = true;
private $request;
/**
* Register the service provider.
......@@ -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->onBackend() === true) {
if ($this->app['asgard.onBackend'] === true) {
$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