Binding as a singleton in an asgard key if we're on the backend or not

parent 4305af60
......@@ -2,6 +2,7 @@
namespace Modules\Core\Providers;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\DB;
......@@ -62,6 +63,9 @@ class CoreServiceProvider extends ServiceProvider
$this->app->singleton('asgard.isInstalled', function () {
return true === env('INSTALLED', false);
});
$this->app->singleton('asgard.onBackend', function () {
return $this->onBackend();
});
$this->registerCommands();
$this->registerServices();
......@@ -310,6 +314,20 @@ class CoreServiceProvider extends ServiceProvider
});
}
/**
* Checks if the current url matches the configured backend uri
* @return bool
*/
private function onBackend()
{
$url = app(Request::class)->url();
if (str_contains($url, config('asgard.core.core.admin-prefix'))) {
return true;
}
return false;
}
/**
* Get argument array from argument string.
* @param $argumentString
......
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