wip
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Clusters\Cards\CardOrders\Schemas;
|
||||
|
||||
use App\Modules\Country\Repositories\CountryRepository;
|
||||
use App\Modules\FilamentPermission\Repositories\FilamentPermissionRepository;
|
||||
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||
use App\Modules\PhoneNumberVerification\Rules\PhoneNumberVerificationRule;
|
||||
use App\Modules\Region\Repositories\RegionRepository;
|
||||
@@ -36,20 +37,8 @@ class CardOrderForm
|
||||
Section::make(__('New card order'))
|
||||
->columnSpan(4)
|
||||
->columns(4)
|
||||
->disabled(function (string $context) {
|
||||
if (user()->isSystemUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
->hidden(function (string $context): bool {
|
||||
if (user()->isSystemUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $context === 'create';
|
||||
})
|
||||
->disabled(fn (string $context): bool => FilamentPermissionRepository::forClients())
|
||||
->hidden(fn (string $context) => FilamentPermissionRepository::defaultSystemInput($context))
|
||||
->components([
|
||||
Select::make('status')
|
||||
->label(__('Status'))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Clusters\Cards\Resources\CardPinOrders\Schemas;
|
||||
|
||||
use App\Modules\FilamentPermission\Repositories\FilamentPermissionRepository;
|
||||
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||
use App\Modules\PhoneNumberVerification\Rules\PhoneNumberVerificationRule;
|
||||
use App\Modules\Region\Repositories\RegionRepository;
|
||||
@@ -29,20 +30,8 @@ class CardPinOrderForm
|
||||
|
||||
Section::make(__('New card pin order'))
|
||||
->columnSpanFull()
|
||||
->disabled(function (string $context) {
|
||||
if (user()->isSystemUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
->hidden(function (string $context): bool {
|
||||
if (user()->isSystemUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $context === 'create';
|
||||
})
|
||||
->disabled(fn (string $context): bool => FilamentPermissionRepository::forClients())
|
||||
->hidden(fn (string $context) => FilamentPermissionRepository::defaultSystemInput($context))
|
||||
->components([
|
||||
Select::make('status')
|
||||
->label(__('Status'))
|
||||
|
||||
@@ -39,6 +39,7 @@ class LoanOrderForm
|
||||
Section::make(__('New loan order'))
|
||||
->columnSpan(4)
|
||||
->columns(4)
|
||||
|
||||
->components([
|
||||
Select::make('status')
|
||||
->label(__('Status'))
|
||||
|
||||
64
app/Modules/FilamentPermission/FilamentPermissionModule.php
Normal file
64
app/Modules/FilamentPermission/FilamentPermissionModule.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\FilamentPermission;
|
||||
|
||||
use App\Modules\Makeable;
|
||||
use App\Modules\ModuleContract;
|
||||
|
||||
class FilamentPermissionModule implements ModuleContract
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
* Module is enabled
|
||||
*/
|
||||
protected bool $enabled = true;
|
||||
|
||||
/**
|
||||
* Check if is module enabled
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable module
|
||||
*/
|
||||
public function disable(): void
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable module
|
||||
*/
|
||||
public function enable(): void
|
||||
{
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if module has a filament resource
|
||||
*/
|
||||
public function hasFilamentResource(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer requirements
|
||||
*/
|
||||
public function getComposerRequirements(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer suggestions
|
||||
*/
|
||||
public function getComposerSuggestions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\FilamentPermission\Repositories;
|
||||
|
||||
class FilamentPermissionRepository
|
||||
{
|
||||
public static function forClients(): bool
|
||||
{
|
||||
return ! user()->isSystemUser();
|
||||
}
|
||||
|
||||
public static function defaultSystemInput(string $context)
|
||||
{
|
||||
if (user()->isSystemUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $context === 'create';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user