40 lines
929 B
PHP
40 lines
929 B
PHP
<?php
|
|
|
|
namespace Modules\Portal\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Modules\Portal\Utils\PortalUtil;
|
|
|
|
abstract class BasePortalController extends Controller
|
|
{
|
|
protected function businessId(): int
|
|
{
|
|
return (int) request()->session()->get('user.business_id');
|
|
}
|
|
|
|
protected function contactId(): ?int
|
|
{
|
|
return auth()->user()->crm_contact_id;
|
|
}
|
|
|
|
protected function ensureCrmSubscription(): void
|
|
{
|
|
$this->ensurePortalAccess();
|
|
}
|
|
|
|
protected function ensurePortalAccess(): void
|
|
{
|
|
$portal = PortalUtil::portalForUserType(auth()->user()->user_type);
|
|
if (! $portal) {
|
|
abort(403, __('portal::lang.portal_access_denied'));
|
|
}
|
|
|
|
PortalUtil::assertPortalAccess(auth()->user(), $portal);
|
|
}
|
|
|
|
protected function portalView(string $name, array $data = [])
|
|
{
|
|
return view($name, $data);
|
|
}
|
|
}
|