added new helpers
This commit is contained in:
parent
e083a10d3d
commit
9af0464dad
|
|
@ -91,7 +91,7 @@ abstract class Widget
|
||||||
|
|
||||||
public function view($name, $data = [])
|
public function view($name, $data = [])
|
||||||
{
|
{
|
||||||
if (request()->isApi()) {
|
if (request_is_api()) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ class Handler extends ExceptionHandler
|
||||||
*/
|
*/
|
||||||
public function render($request, Throwable $exception)
|
public function render($request, Throwable $exception)
|
||||||
{
|
{
|
||||||
if ($request->isApi()) {
|
if (request_is_api($request)) {
|
||||||
return $this->handleApiExceptions($request, $exception);
|
return $this->handleApiExceptions($request, $exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ trait Companies
|
||||||
|
|
||||||
$request = $this->request ?: request();
|
$request = $this->request ?: request();
|
||||||
|
|
||||||
if ($this->isCompanyApiRequest($request)) {
|
if (request_is_api($request)) {
|
||||||
return $this->getCompanyIdFromApi($request);
|
return $this->getCompanyIdFromApi($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,9 +54,4 @@ trait Companies
|
||||||
{
|
{
|
||||||
return (int) $request->header('X-Company');
|
return (int) $request->header('X-Company');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isCompanyApiRequest($request)
|
|
||||||
{
|
|
||||||
return $request->is(config('api.prefix') . '/*');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -429,7 +429,7 @@ trait Permissions
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = request()->isApi() ? request()->segment(2) : '';
|
$table = request_is_api() ? request()->segment(2) : '';
|
||||||
|
|
||||||
// Find the proper controller for common API endpoints
|
// Find the proper controller for common API endpoints
|
||||||
if (in_array($table, ['contacts', 'documents'])) {
|
if (in_array($table, ['contacts', 'documents'])) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ trait Trackers
|
||||||
$app_type = 'queue';
|
$app_type = 'queue';
|
||||||
} elseif (Str::contains($hostname, '-cron-')) {
|
} elseif (Str::contains($hostname, '-cron-')) {
|
||||||
$app_type = 'cron';
|
$app_type = 'cron';
|
||||||
} elseif (request()->isApi()) {
|
} elseif (request_is_api()) {
|
||||||
$app_type = 'api';
|
$app_type = 'api';
|
||||||
} elseif (app()->runningInConsole()) {
|
} elseif (app()->runningInConsole()) {
|
||||||
$app_type = 'console';
|
$app_type = 'console';
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use App\Traits\Modules;
|
||||||
use App\Traits\SearchString;
|
use App\Traits\SearchString;
|
||||||
use App\Utilities\Date;
|
use App\Utilities\Date;
|
||||||
use App\Utilities\Widgets;
|
use App\Utilities\Widgets;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
if (! function_exists('user')) {
|
if (! function_exists('user')) {
|
||||||
|
|
@ -313,3 +314,39 @@ if (! function_exists('is_cloud')) {
|
||||||
return $cloud->isCloud();
|
return $cloud->isCloud();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! function_exists('request_is_api')) {
|
||||||
|
function request_is_api(Request|null $request = null): bool
|
||||||
|
{
|
||||||
|
$r = $request ?: request();
|
||||||
|
|
||||||
|
return $r->is(config('api.prefix') . '/*');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('request_is_auth')) {
|
||||||
|
function request_is_auth(Request|null $request = null): bool
|
||||||
|
{
|
||||||
|
$r = $request ?: request();
|
||||||
|
|
||||||
|
return $r->is('auth/*');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('request_is_signed')) {
|
||||||
|
function request_is_signed(Request|null $request = null, int $company_id): bool
|
||||||
|
{
|
||||||
|
$r = $request ?: request();
|
||||||
|
|
||||||
|
return $r->is($company_id . '/signed/*');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('request_is_portal')) {
|
||||||
|
function request_is_portal(Request|null $request = null, int $company_id): bool
|
||||||
|
{
|
||||||
|
$r = $request ?: request();
|
||||||
|
|
||||||
|
return $r->is($company_id . '/portal') || $r->is($company_id . '/portal/*');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue