Created
September 26, 2018 09:54
-
-
Save EngEryx/fdc4b17adaa43bae79b18a14dc8dea50 to your computer and use it in GitHub Desktop.
Helper functions you could consider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(! function_exists('client_app')){ | |
/* | |
* Get the client application instance. | |
* | |
*/ | |
function client_app(){ | |
$hostname = mnet_client(); | |
$client = \App\Models\Client\Client::where('hostname_id',$hostname->id)->first(); | |
return $client; | |
} | |
} | |
if(! function_exists('client_app_id')){ | |
/* | |
* Get the data filter id for the client. | |
* | |
*/ | |
function client_app_id(){ | |
return client_app()->id; | |
} | |
} | |
if(! function_exists('is_client_admin')){ | |
/* | |
* Determine is the logged user at the client site is the owner. | |
*/ | |
function is_client_admin(){ | |
return auth()->user()->client_id == client_app_id() | |
&& auth()->user()->user_group==config('access.user_groups.client'); | |
} | |
} | |
if (! function_exists('is_client')) { | |
/** | |
* Helper to grab the application name. | |
* | |
* @return mixed | |
*/ | |
function is_client() | |
{ | |
$tenancy = app(Environment::class); | |
return $tenancy->hostname() ? true : false; | |
} | |
} | |
if (! function_exists('mnet_client')) { | |
/** | |
* Helper to grab the application name. | |
* | |
* @return mixed | |
*/ | |
function mnet_client() | |
{ | |
$tenancy = app(Environment::class); | |
return $tenancy->hostname(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment