In some places of my code I need to check if it's a backend area or a public page. I wrote a simple function in my Utils
class.
static public function isInBackend()
{
return (strpos(Url::current(), Config::get('cms.backendUri', 'backend')) !== false);
}
Does anyone know better ways to check that?
It's very easy in OctoberCMS to check whether you are in backend or not; just see below code for that:
if(\App::runningInBackend()) {
//write your code here
}
You can learn more from this documentation link: https://octobercms.com/docs/services/application#application-helpers