diff --git a/demo/app/Console/Kernel.php b/demo/app/Console/Kernel.php index d8bc1d29f..854bcc8a9 100644 --- a/demo/app/Console/Kernel.php +++ b/demo/app/Console/Kernel.php @@ -10,7 +10,6 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. * - * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) diff --git a/demo/app/Http/Middleware/RedirectIfAuthenticated.php b/demo/app/Http/Middleware/RedirectIfAuthenticated.php index a2813a064..4e7c24b7e 100644 --- a/demo/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/demo/app/Http/Middleware/RedirectIfAuthenticated.php @@ -12,7 +12,6 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next * @param string|null ...$guards * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse diff --git a/demo/app/Models/Post.php b/demo/app/Models/Post.php index 5ff6da2fe..12537dbb8 100644 --- a/demo/app/Models/Post.php +++ b/demo/app/Models/Post.php @@ -21,7 +21,9 @@ class Post extends Model 'title', 'content', ]; + protected $guarded = []; + protected $casts = [ 'published_at' => 'datetime', 'state' => PostState::class, diff --git a/demo/app/Providers/AppServiceProvider.php b/demo/app/Providers/AppServiceProvider.php index 49185f5ee..b21a4f0ae 100644 --- a/demo/app/Providers/AppServiceProvider.php +++ b/demo/app/Providers/AppServiceProvider.php @@ -11,7 +11,7 @@ class AppServiceProvider extends ServiceProvider public function register() { $this->app->register(SharpServiceProvider::class); -// $this->app->bind(SharpUploadModel::class, Media::class) + // $this->app->bind(SharpUploadModel::class, Media::class) $this->app->bind(SharpViteComponent::class, function () { return new SharpViteComponent(hotFile: base_path('../resources/assets/dist/hot')); diff --git a/demo/app/Sharp/Categories/CategoryForm.php b/demo/app/Sharp/Categories/CategoryForm.php index 0fbf94ca6..5082ff8a9 100644 --- a/demo/app/Sharp/Categories/CategoryForm.php +++ b/demo/app/Sharp/Categories/CategoryForm.php @@ -47,7 +47,7 @@ public function update($id, array $data) { $category = $id ? Category::findOrFail($id) - : new Category(); + : new Category; $this->save($category, $data); diff --git a/demo/app/Sharp/Dashboard/DemoDashboard.php b/demo/app/Sharp/Dashboard/DemoDashboard.php index e5b47c109..b0a80e26d 100644 --- a/demo/app/Sharp/Dashboard/DemoDashboard.php +++ b/demo/app/Sharp/Dashboard/DemoDashboard.php @@ -37,6 +37,7 @@ class DemoDashboard extends SharpDashboard '#78350F', '#9CA3AF', ]; + private static int $colorsIndex = 0; protected function buildWidgets(WidgetsContainer $widgetsContainer): void @@ -213,7 +214,7 @@ protected function setPieGraphDataSet(): void private static function nextColor(): string { - if (static::$colorsIndex >= sizeof(static::$colors)) { + if (static::$colorsIndex >= count(static::$colors)) { static::$colorsIndex = 0; } diff --git a/demo/app/Sharp/Entities/AuthorEntity.php b/demo/app/Sharp/Entities/AuthorEntity.php index b03d87507..548e36d72 100644 --- a/demo/app/Sharp/Entities/AuthorEntity.php +++ b/demo/app/Sharp/Entities/AuthorEntity.php @@ -8,5 +8,6 @@ class AuthorEntity extends SharpEntity { protected ?string $list = AuthorList::class; + protected array $prohibitedActions = ['view', 'update', 'delete', 'create']; } diff --git a/demo/app/Sharp/Entities/CategoryEntity.php b/demo/app/Sharp/Entities/CategoryEntity.php index 6ed030ad6..0ef0296ca 100644 --- a/demo/app/Sharp/Entities/CategoryEntity.php +++ b/demo/app/Sharp/Entities/CategoryEntity.php @@ -10,6 +10,8 @@ class CategoryEntity extends SharpEntity { protected ?string $list = CategoryList::class; + protected ?string $show = CategoryShow::class; + protected ?string $form = CategoryForm::class; } diff --git a/demo/app/Sharp/Entities/PostBlockEntity.php b/demo/app/Sharp/Entities/PostBlockEntity.php index 19388ca1c..11b5a0d45 100644 --- a/demo/app/Sharp/Entities/PostBlockEntity.php +++ b/demo/app/Sharp/Entities/PostBlockEntity.php @@ -12,7 +12,9 @@ class PostBlockEntity extends SharpEntity { protected ?string $list = PostBlockList::class; + protected ?string $policy = PostBlockPolicy::class; + protected string $label = 'Block'; public function getMultiforms(): array diff --git a/demo/app/Sharp/Entities/PostEntity.php b/demo/app/Sharp/Entities/PostEntity.php index 0ef73f480..e58428d65 100644 --- a/demo/app/Sharp/Entities/PostEntity.php +++ b/demo/app/Sharp/Entities/PostEntity.php @@ -11,7 +11,10 @@ class PostEntity extends SharpEntity { protected ?string $list = PostList::class; + protected ?string $show = PostShow::class; + protected ?string $form = PostForm::class; + protected ?string $policy = PostPolicy::class; } diff --git a/demo/app/Sharp/Entities/ProfileEntity.php b/demo/app/Sharp/Entities/ProfileEntity.php index 2fb331a2f..1ca53463f 100644 --- a/demo/app/Sharp/Entities/ProfileEntity.php +++ b/demo/app/Sharp/Entities/ProfileEntity.php @@ -9,7 +9,10 @@ class ProfileEntity extends SharpEntity { protected bool $isSingle = true; + protected ?string $show = ProfileSingleShow::class; + protected ?string $form = ProfileSingleForm::class; + protected string $label = 'My profile'; } diff --git a/demo/app/Sharp/Entities/TestEntity.php b/demo/app/Sharp/Entities/TestEntity.php index c7d6e6238..0c24de5a9 100644 --- a/demo/app/Sharp/Entities/TestEntity.php +++ b/demo/app/Sharp/Entities/TestEntity.php @@ -7,8 +7,12 @@ class TestEntity extends SharpEntity { protected bool $isSingle = true; + protected ?string $show = \App\Sharp\TestForm\TestShow::class; + protected ?string $form = \App\Sharp\TestForm\TestForm::class; + protected ?string $policy = \App\Sharp\TestForm\TestPolicy::class; + protected string $label = 'Test'; } diff --git a/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php b/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php index 2d9d473a6..6cc4852da 100644 --- a/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php +++ b/demo/app/Sharp/Posts/Blocks/AbstractPostBlockForm.php @@ -17,6 +17,7 @@ abstract class AbstractPostBlockForm extends SharpForm use WithSharpFormEloquentUpdater; protected static string $postBlockType = 'none'; + protected static string $postBlockHelpText = ''; public function buildFormFields(FieldsContainer $formFields): void @@ -46,9 +47,7 @@ public function buildFormLayout(FormLayout $formLayout): void }); } - public function buildFormConfig(): void - { - } + public function buildFormConfig(): void {} public function find($id): array { @@ -100,11 +99,7 @@ protected function getContentField(): ?SharpFormField ->setRowCount(6); } - protected function buildAdditionalFields(FieldsContainer $formFields): void - { - } + protected function buildAdditionalFields(FieldsContainer $formFields): void {} - protected function addAdditionalFieldsToLayout(FormLayoutColumn $column): void - { - } + protected function addAdditionalFieldsToLayout(FormLayoutColumn $column): void {} } diff --git a/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php b/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php index c0d1523fd..cdc5991aa 100644 --- a/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php +++ b/demo/app/Sharp/Posts/Blocks/PostBlockTextForm.php @@ -8,6 +8,7 @@ class PostBlockTextForm extends AbstractPostBlockForm { protected static string $postBlockType = 'text'; + protected ?string $formValidatorClass = PostBlockTextValidator::class; protected function getContentField(): ?SharpFormField diff --git a/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php b/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php index 295a8fffe..3b80b5e1a 100644 --- a/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php +++ b/demo/app/Sharp/Posts/Blocks/PostBlockVideoForm.php @@ -5,6 +5,8 @@ class PostBlockVideoForm extends AbstractPostBlockForm { protected static string $postBlockType = 'video'; + protected static string $postBlockHelpText = 'Please provide a valid Youtube embed text'; + protected ?string $formValidatorClass = PostBlockVideoValidator::class; } diff --git a/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php b/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php index 6e2638cb0..937bfad2e 100644 --- a/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php +++ b/demo/app/Sharp/Posts/Blocks/PostBlockVisualsForm.php @@ -13,6 +13,7 @@ class PostBlockVisualsForm extends AbstractPostBlockForm { protected static string $postBlockType = 'visuals'; + protected ?string $formValidatorClass = PostBlockVisualsValidator::class; protected function getContentField(): ?SharpFormField @@ -60,6 +61,6 @@ protected function addAdditionalFieldsToLayout(FormLayoutColumn $column): void protected function addCustomTransformers(): self { - return $this->setCustomTransformer('files', new SharpUploadModelFormAttributeTransformer()); + return $this->setCustomTransformer('files', new SharpUploadModelFormAttributeTransformer); } } diff --git a/demo/app/Sharp/Posts/PostForm.php b/demo/app/Sharp/Posts/PostForm.php index 72011fa76..94036fba2 100644 --- a/demo/app/Sharp/Posts/PostForm.php +++ b/demo/app/Sharp/Posts/PostForm.php @@ -188,8 +188,8 @@ public function find($id): array ->setCustomTransformer('author_id', function ($value, Post $instance) { return $instance->author; }) - ->setCustomTransformer('cover', new SharpUploadModelFormAttributeTransformer()) - ->setCustomTransformer('attachments[document]', new SharpUploadModelFormAttributeTransformer()) + ->setCustomTransformer('cover', new SharpUploadModelFormAttributeTransformer) + ->setCustomTransformer('attachments[document]', new SharpUploadModelFormAttributeTransformer) ->transform(Post::with('cover', 'attachments', 'categories')->findOrFail($id)); } diff --git a/demo/app/Sharp/Profile/ProfileSingleForm.php b/demo/app/Sharp/Profile/ProfileSingleForm.php index 692a3af7f..e5887a10f 100644 --- a/demo/app/Sharp/Profile/ProfileSingleForm.php +++ b/demo/app/Sharp/Profile/ProfileSingleForm.php @@ -61,7 +61,7 @@ public function buildFormLayout(FormLayout $formLayout): void public function findSingle(): array { return $this - ->setCustomTransformer('avatar', new SharpUploadModelFormAttributeTransformer()) + ->setCustomTransformer('avatar', new SharpUploadModelFormAttributeTransformer) ->transform(auth()->user()); } diff --git a/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php b/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php index 51d743ca7..36997a086 100644 --- a/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php +++ b/demo/app/Sharp/Utils/Embeds/AuthorEmbed.php @@ -55,7 +55,7 @@ public function transformDataForTemplate(array $data, bool $isForm): array return $user?->name; }) - ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer())->dynamicInstance()) + ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer)->dynamicInstance()) ->transformForTemplate($data); } @@ -69,7 +69,7 @@ public function transformDataForFormFields(array $data): array ? Arr::only($user, ['id', 'name', 'email']) : null; }) - ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer())->dynamicInstance()) + ->setCustomTransformer('picture', (new SharpUploadModelFormAttributeTransformer)->dynamicInstance()) ->transform($data); } diff --git a/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php b/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php index 157c04cbf..84073e047 100644 --- a/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php +++ b/demo/app/Sharp/Utils/Embeds/TableOfContentsEmbed.php @@ -14,11 +14,7 @@ public function buildEmbedConfig(): void ->configureFormInlineTemplate('- Table of contents -'); } - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} - public function updateContent(array $data = []): array - { - } + public function updateContent(array $data = []): array {} } diff --git a/src/Auth/SharpAuthorizationManager.php b/src/Auth/SharpAuthorizationManager.php index 5a202c5d7..c57868adb 100644 --- a/src/Auth/SharpAuthorizationManager.php +++ b/src/Auth/SharpAuthorizationManager.php @@ -11,9 +11,7 @@ class SharpAuthorizationManager { private array $cachedPolicies = []; - public function __construct(protected SharpEntityManager $entityManager, protected Gate $gate) - { - } + public function __construct(protected SharpEntityManager $entityManager, protected Gate $gate) {} public function isAllowed(string $ability, string $entityKey, ?string $instanceId = null): bool { diff --git a/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php b/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php index 5077b1ce8..6f4a411a4 100644 --- a/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php +++ b/src/Auth/TwoFactor/Commands/Activate2faViaTotpWizardCommandTrait.php @@ -71,7 +71,7 @@ protected function initialDataForStepConfirm(): array new SvgImageBackEnd ) )) - ->writeString($this->get2faHandler()->setUser(auth()->user())->getQRCodeUrl()); + ->writeString($this->get2faHandler()->setUser(auth()->user())->getQRCodeUrl()); return [ 'qr' => [ diff --git a/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php b/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php index acc301835..f85e07348 100644 --- a/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php +++ b/src/Auth/TwoFactor/Engines/GoogleTotpEngine.php @@ -6,9 +6,7 @@ class GoogleTotpEngine implements Sharp2faTotpEngine { - public function __construct(protected Google2FA $google2fa) - { - } + public function __construct(protected Google2FA $google2fa) {} public function verify(string $code, string $secret): bool { diff --git a/src/Auth/TwoFactor/Sharp2faDefaultNotification.php b/src/Auth/TwoFactor/Sharp2faDefaultNotification.php index 74d4b1af2..8a38f9141 100644 --- a/src/Auth/TwoFactor/Sharp2faDefaultNotification.php +++ b/src/Auth/TwoFactor/Sharp2faDefaultNotification.php @@ -10,9 +10,7 @@ class Sharp2faDefaultNotification extends Notification implements ShouldQueue { use \Illuminate\Bus\Queueable; - public function __construct(public string $code) - { - } + public function __construct(public string $code) {} public function via($notifiable) { diff --git a/src/Auth/TwoFactor/Sharp2faTotpHandler.php b/src/Auth/TwoFactor/Sharp2faTotpHandler.php index bb32e71e7..762b76b41 100644 --- a/src/Auth/TwoFactor/Sharp2faTotpHandler.php +++ b/src/Auth/TwoFactor/Sharp2faTotpHandler.php @@ -11,9 +11,7 @@ abstract class Sharp2faTotpHandler implements Sharp2faHandler { protected $user = null; - public function __construct(protected Sharp2faTotpEngine $engine) - { - } + public function __construct(protected Sharp2faTotpEngine $engine) {} public function generateCode(bool $remember = false): void { diff --git a/src/Console/DashboardMakeCommand.php b/src/Console/DashboardMakeCommand.php index a9a6b534c..194defbf7 100644 --- a/src/Console/DashboardMakeCommand.php +++ b/src/Console/DashboardMakeCommand.php @@ -7,7 +7,9 @@ class DashboardMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:dashboard'; + protected $description = 'Create a new Dashboard'; + protected $type = 'Dashboard'; protected function getStub() diff --git a/src/Console/EntityCommandMakeCommand.php b/src/Console/EntityCommandMakeCommand.php index 0908ed775..87e496d16 100644 --- a/src/Console/EntityCommandMakeCommand.php +++ b/src/Console/EntityCommandMakeCommand.php @@ -8,7 +8,9 @@ class EntityCommandMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:entity-command'; + protected $description = 'Create a new Entity List Command class'; + protected $type = 'EntityCommand'; protected function getStub() diff --git a/src/Console/EntityListFilterMakeCommand.php b/src/Console/EntityListFilterMakeCommand.php index ec572cef2..8b56e2db3 100644 --- a/src/Console/EntityListFilterMakeCommand.php +++ b/src/Console/EntityListFilterMakeCommand.php @@ -8,7 +8,9 @@ class EntityListFilterMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:entity-list-filter'; + protected $description = 'Create a new Entity List Filter class'; + protected $type = 'EntityListFilter'; protected function getStub() diff --git a/src/Console/EntityListMakeCommand.php b/src/Console/EntityListMakeCommand.php index 6bd36a6b1..b763c25fa 100644 --- a/src/Console/EntityListMakeCommand.php +++ b/src/Console/EntityListMakeCommand.php @@ -11,7 +11,9 @@ class EntityListMakeCommand extends GeneratorCommand use WithModel; protected $name = 'sharp:make:entity-list'; + protected $description = 'Create a new Entity List class'; + protected $type = 'SharpEntityList'; protected function buildClass($name) diff --git a/src/Console/FormMakeCommand.php b/src/Console/FormMakeCommand.php index 5b13e8c27..4b0e8d2e4 100644 --- a/src/Console/FormMakeCommand.php +++ b/src/Console/FormMakeCommand.php @@ -11,7 +11,9 @@ class FormMakeCommand extends GeneratorCommand use WithModel; protected $name = 'sharp:make:form'; + protected $description = 'Create a new Form class'; + protected $type = 'SharpForm'; protected function buildClass($name) diff --git a/src/Console/InstanceCommandMakeCommand.php b/src/Console/InstanceCommandMakeCommand.php index 4feb5fb6d..b9b208d6a 100644 --- a/src/Console/InstanceCommandMakeCommand.php +++ b/src/Console/InstanceCommandMakeCommand.php @@ -8,7 +8,9 @@ class InstanceCommandMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:instance-command'; + protected $description = 'Create a new instance Command class'; + protected $type = 'InstanceCommand'; protected function getStub() diff --git a/src/Console/MediaMakeCommand.php b/src/Console/MediaMakeCommand.php index 72566ea67..866fe5287 100644 --- a/src/Console/MediaMakeCommand.php +++ b/src/Console/MediaMakeCommand.php @@ -8,7 +8,9 @@ class MediaMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:media'; + protected $description = 'Create the media model for sharp uploads'; + protected $type = 'Media model'; protected function getStub() diff --git a/src/Console/ReorderHandlerMakeCommand.php b/src/Console/ReorderHandlerMakeCommand.php index e015d9474..bde3f8a28 100644 --- a/src/Console/ReorderHandlerMakeCommand.php +++ b/src/Console/ReorderHandlerMakeCommand.php @@ -10,7 +10,9 @@ class ReorderHandlerMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:reorder-handler'; + protected $description = 'Create a new Reorder Handler class'; + protected $type = 'ReorderHandler'; protected function buildClass($name) diff --git a/src/Console/ShowPageMakeCommand.php b/src/Console/ShowPageMakeCommand.php index 9767e3645..ff6179eb5 100644 --- a/src/Console/ShowPageMakeCommand.php +++ b/src/Console/ShowPageMakeCommand.php @@ -11,7 +11,9 @@ class ShowPageMakeCommand extends GeneratorCommand use WithModel; protected $name = 'sharp:make:show-page'; + protected $description = 'Create a new Show Page class'; + protected $type = 'SharpShow'; protected function buildClass($name) diff --git a/src/Console/StateMakeCommand.php b/src/Console/StateMakeCommand.php index f9f4e3d53..79f501e5c 100644 --- a/src/Console/StateMakeCommand.php +++ b/src/Console/StateMakeCommand.php @@ -10,7 +10,9 @@ class StateMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:entity-state'; + protected $description = 'Create a new Entity State class'; + protected $type = 'EntityState'; protected function buildClass($name) diff --git a/src/Console/ValidatorMakeCommand.php b/src/Console/ValidatorMakeCommand.php index c9012e810..14325d594 100644 --- a/src/Console/ValidatorMakeCommand.php +++ b/src/Console/ValidatorMakeCommand.php @@ -7,7 +7,9 @@ class ValidatorMakeCommand extends GeneratorCommand { protected $name = 'sharp:make:validator'; + protected $description = 'Create a new Form Validator class'; + protected $type = 'Validator'; protected function getStub() diff --git a/src/Dashboard/Commands/DashboardWizardCommand.php b/src/Dashboard/Commands/DashboardWizardCommand.php index 34be780d0..887969ef5 100644 --- a/src/Dashboard/Commands/DashboardWizardCommand.php +++ b/src/Dashboard/Commands/DashboardWizardCommand.php @@ -8,7 +8,7 @@ abstract class DashboardWizardCommand extends DashboardCommand { - use IsWizardCommand, IsEntityWizardCommand; + use IsEntityWizardCommand, IsWizardCommand; abstract protected function buildFormFieldsForFirstStep(FieldsContainer $formFields): void; } diff --git a/src/Dashboard/Filters/DashboardCheckFilter.php b/src/Dashboard/Filters/DashboardCheckFilter.php index 188d7eb92..dde07936b 100644 --- a/src/Dashboard/Filters/DashboardCheckFilter.php +++ b/src/Dashboard/Filters/DashboardCheckFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\CheckFilter; -class DashboardCheckFilter extends CheckFilter -{ -} +class DashboardCheckFilter extends CheckFilter {} diff --git a/src/Dashboard/Filters/DashboardDateRangeFilter.php b/src/Dashboard/Filters/DashboardDateRangeFilter.php index 66b6c325a..d8c8bc4da 100644 --- a/src/Dashboard/Filters/DashboardDateRangeFilter.php +++ b/src/Dashboard/Filters/DashboardDateRangeFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeFilter; -abstract class DashboardDateRangeFilter extends DateRangeFilter -{ -} +abstract class DashboardDateRangeFilter extends DateRangeFilter {} diff --git a/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php b/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php index 13bc03360..959661c1d 100644 --- a/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php +++ b/src/Dashboard/Filters/DashboardDateRangeRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeRequiredFilter; -abstract class DashboardDateRangeRequiredFilter extends DateRangeRequiredFilter -{ -} +abstract class DashboardDateRangeRequiredFilter extends DateRangeRequiredFilter {} diff --git a/src/Dashboard/Filters/DashboardSelectFilter.php b/src/Dashboard/Filters/DashboardSelectFilter.php index 5f70bd6d2..e9724a9b4 100644 --- a/src/Dashboard/Filters/DashboardSelectFilter.php +++ b/src/Dashboard/Filters/DashboardSelectFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectFilter; -abstract class DashboardSelectFilter extends SelectFilter -{ -} +abstract class DashboardSelectFilter extends SelectFilter {} diff --git a/src/Dashboard/Filters/DashboardSelectMultipleFilter.php b/src/Dashboard/Filters/DashboardSelectMultipleFilter.php index d10a9afc5..541f6c792 100644 --- a/src/Dashboard/Filters/DashboardSelectMultipleFilter.php +++ b/src/Dashboard/Filters/DashboardSelectMultipleFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectMultipleFilter; -abstract class DashboardSelectMultipleFilter extends SelectMultipleFilter -{ -} +abstract class DashboardSelectMultipleFilter extends SelectMultipleFilter {} diff --git a/src/Dashboard/Filters/DashboardSelectRequiredFilter.php b/src/Dashboard/Filters/DashboardSelectRequiredFilter.php index 1f8eea17e..6688b8992 100644 --- a/src/Dashboard/Filters/DashboardSelectRequiredFilter.php +++ b/src/Dashboard/Filters/DashboardSelectRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectRequiredFilter; -abstract class DashboardSelectRequiredFilter extends SelectRequiredFilter -{ -} +abstract class DashboardSelectRequiredFilter extends SelectRequiredFilter {} diff --git a/src/Dashboard/Layout/DashboardLayout.php b/src/Dashboard/Layout/DashboardLayout.php index 802620e78..3ee709fb5 100644 --- a/src/Dashboard/Layout/DashboardLayout.php +++ b/src/Dashboard/Layout/DashboardLayout.php @@ -22,7 +22,7 @@ final public function addRow(Closure $callback): self { $row = $this ->getLonelySection() - ->addRowLayout(new DashboardLayoutRow()); + ->addRowLayout(new DashboardLayoutRow); $callback($row); @@ -38,7 +38,7 @@ final public function addFullWidthWidget(string $widgetKey): self private function getLonelySection(): DashboardLayoutSection { - if (! sizeof($this->sections)) { + if (! count($this->sections)) { return $this->addSectionLayout(new DashboardLayoutSection('')); } diff --git a/src/Dashboard/Layout/DashboardLayoutSection.php b/src/Dashboard/Layout/DashboardLayoutSection.php index bfed778e8..80814bf13 100644 --- a/src/Dashboard/Layout/DashboardLayoutSection.php +++ b/src/Dashboard/Layout/DashboardLayoutSection.php @@ -7,15 +7,14 @@ class DashboardLayoutSection { protected array $rows = []; + protected ?string $sectionKey = null; - public function __construct(protected string $title) - { - } + public function __construct(protected string $title) {} final public function addRow(Closure $callback): self { - $row = new DashboardLayoutRow(); + $row = new DashboardLayoutRow; $callback($row); $this->rows[] = $row; diff --git a/src/Dashboard/SharpDashboard.php b/src/Dashboard/SharpDashboard.php index 32782344e..5e89488cb 100644 --- a/src/Dashboard/SharpDashboard.php +++ b/src/Dashboard/SharpDashboard.php @@ -15,18 +15,26 @@ abstract class SharpDashboard { - use HandleFilters, - HandleDashboardCommands, + use HandleDashboardCommands, + HandleFilters, HandlePageAlertMessage; protected bool $dashboardBuilt = false; + protected array $graphWidgetDataSets = []; + protected array $panelWidgetsData = []; + protected array $figureWidgetsData = []; + protected array $orderedListWidgetsData = []; + protected ?array $pageAlertData = null; + protected ?DashboardQueryParams $queryParams; + protected ?DashboardLayout $dashboardLayout = null; + protected ?WidgetsContainer $widgetsContainer = null; final public function init(): self @@ -58,7 +66,7 @@ final public function widgets(): array final public function widgetsContainer(): WidgetsContainer { if ($this->widgetsContainer === null) { - $this->widgetsContainer = new WidgetsContainer(); + $this->widgetsContainer = new WidgetsContainer; } return $this->widgetsContainer; @@ -67,7 +75,7 @@ final public function widgetsContainer(): WidgetsContainer final public function widgetsLayout(): array { if ($this->dashboardLayout === null) { - $this->dashboardLayout = new DashboardLayout(); + $this->dashboardLayout = new DashboardLayout; $this->buildDashboardLayout($this->dashboardLayout); } @@ -77,9 +85,7 @@ final public function widgetsLayout(): array /** * Build config if necessary. */ - public function buildDashboardConfig(): void - { - } + public function buildDashboardConfig(): void {} /** * Return all filters in an array of class names or instances. diff --git a/src/Dashboard/Widgets/SharpBarGraphWidget.php b/src/Dashboard/Widgets/SharpBarGraphWidget.php index 1cf4a4738..b8c779528 100644 --- a/src/Dashboard/Widgets/SharpBarGraphWidget.php +++ b/src/Dashboard/Widgets/SharpBarGraphWidget.php @@ -5,6 +5,7 @@ class SharpBarGraphWidget extends SharpGraphWidget { protected bool $horizontal = false; + protected bool $displayHorizontalAxisAsTimeline = false; public static function make(string $key): SharpBarGraphWidget diff --git a/src/Dashboard/Widgets/SharpGraphWidget.php b/src/Dashboard/Widgets/SharpGraphWidget.php index 53a08eb78..079ed004d 100644 --- a/src/Dashboard/Widgets/SharpGraphWidget.php +++ b/src/Dashboard/Widgets/SharpGraphWidget.php @@ -5,9 +5,13 @@ abstract class SharpGraphWidget extends SharpWidget { protected ?string $display = null; + protected array $ratio = [16, 9]; + protected ?int $height = null; + protected bool $showLegend = true; + protected bool $minimal = false; public function setRatio(string $ratio): self diff --git a/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php b/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php index 9ca37471c..bce1b0692 100644 --- a/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php +++ b/src/Dashboard/Widgets/SharpGraphWidgetDataSet.php @@ -7,7 +7,9 @@ class SharpGraphWidgetDataSet { protected array $values; + protected ?string $label = null; + protected ?string $color = null; protected function __construct(array|Collection $values) diff --git a/src/Dashboard/Widgets/SharpLineGraphWidget.php b/src/Dashboard/Widgets/SharpLineGraphWidget.php index 18e34cca9..bf3e75bf2 100644 --- a/src/Dashboard/Widgets/SharpLineGraphWidget.php +++ b/src/Dashboard/Widgets/SharpLineGraphWidget.php @@ -5,6 +5,7 @@ class SharpLineGraphWidget extends SharpGraphWidget { protected bool $curvedLines = true; + protected bool $displayHorizontalAxisAsTimeline = false; public static function make(string $key): SharpLineGraphWidget diff --git a/src/Dashboard/Widgets/SharpOrderedListWidget.php b/src/Dashboard/Widgets/SharpOrderedListWidget.php index 78a5c3dcd..f32596217 100644 --- a/src/Dashboard/Widgets/SharpOrderedListWidget.php +++ b/src/Dashboard/Widgets/SharpOrderedListWidget.php @@ -8,6 +8,7 @@ class SharpOrderedListWidget extends SharpWidget { protected ?Closure $itemLinkBuilderClosure = null; + protected bool $html = false; public static function make(string $key): self diff --git a/src/Dashboard/Widgets/SharpWidget.php b/src/Dashboard/Widgets/SharpWidget.php index e4324fa19..01743da64 100644 --- a/src/Dashboard/Widgets/SharpWidget.php +++ b/src/Dashboard/Widgets/SharpWidget.php @@ -9,8 +9,11 @@ abstract class SharpWidget { protected string $key; + protected string $type; + protected ?string $title = null; + protected ?string $link = null; protected function __construct(string $key, string $type) @@ -70,9 +73,9 @@ protected function buildArray(array $childArray): array 'title' => $this->title, 'link' => $this->link, ]) - ->merge($childArray) - ->filter(fn ($value) => $value !== null) - ->all(), + ->merge($childArray) + ->filter(fn ($value) => $value !== null) + ->all(), fn ($array) => $this->validate($array) ); } diff --git a/src/EntityList/Commands/Command.php b/src/EntityList/Commands/Command.php index 0aea83e9e..7a5d2a809 100644 --- a/src/EntityList/Commands/Command.php +++ b/src/EntityList/Commands/Command.php @@ -14,14 +14,19 @@ abstract class Command { use HandleFormFields, HandlePageAlertMessage, - WithCustomTransformers, - HandleValidation; + HandleValidation, + WithCustomTransformers; protected int $groupIndex = 0; + protected ?string $commandKey = null; + private ?string $formModalTitle = null; + private ?string $formModalButtonLabel = null; + private ?string $confirmationText = null; + private ?string $description = null; protected function info(string $message): array @@ -62,7 +67,7 @@ protected function view(string $bladeView, array $params = []): array 'html' => view($bladeView, $params)->render(), ]; } - + protected function html(string $htmlContent): array { return [ @@ -71,7 +76,7 @@ protected function html(string $htmlContent): array ]; } - protected function download(string $filePath, string $fileName = null, string $diskName = null): array + protected function download(string $filePath, ?string $fileName = null, ?string $diskName = null): array { return [ 'action' => 'download', @@ -159,23 +164,17 @@ final public function getFormModalButtonLabel(): ?string /** * Build the optional Command config with configure... methods. */ - public function buildCommandConfig(): void - { - } + public function buildCommandConfig(): void {} /** * Build the optional Command form. */ - public function buildFormFields(FieldsContainer $formFields): void - { - } + public function buildFormFields(FieldsContainer $formFields): void {} /** * Build the optional Command form layout. */ - public function buildFormLayout(FormLayoutColumn &$column): void - { - } + public function buildFormLayout(FormLayoutColumn &$column): void {} final public function commandFormConfig(): ?array { diff --git a/src/EntityList/Commands/EntityCommand.php b/src/EntityList/Commands/EntityCommand.php index 40c323aab..0615215e6 100644 --- a/src/EntityList/Commands/EntityCommand.php +++ b/src/EntityList/Commands/EntityCommand.php @@ -7,6 +7,7 @@ abstract class EntityCommand extends Command { protected ?EntityListQueryParams $queryParams = null; + protected ?string $instanceSelectionMode = null; public function type(): string diff --git a/src/EntityList/Commands/EntityState.php b/src/EntityList/Commands/EntityState.php index 233cf5db3..67e9fabfe 100644 --- a/src/EntityList/Commands/EntityState.php +++ b/src/EntityList/Commands/EntityState.php @@ -19,7 +19,7 @@ public function states(): array return $this->states; } - protected function addState(string $key, string $label, string $color = null): self + protected function addState(string $key, string $label, ?string $color = null): self { $this->states[$key] = [$label, $color]; @@ -38,8 +38,6 @@ protected function info(string $message): array /** * @param mixed $instanceId - * @param array $data - * @return array * * @throws SharpInvalidEntityStateException */ @@ -64,7 +62,6 @@ abstract protected function buildStates(): void; /** * @param mixed $instanceId - * @param string $stateId * @return mixed */ abstract protected function updateState($instanceId, string $stateId): array; diff --git a/src/EntityList/Commands/Wizards/EntityWizardCommand.php b/src/EntityList/Commands/Wizards/EntityWizardCommand.php index 86087c554..4d242d6f0 100644 --- a/src/EntityList/Commands/Wizards/EntityWizardCommand.php +++ b/src/EntityList/Commands/Wizards/EntityWizardCommand.php @@ -7,7 +7,7 @@ abstract class EntityWizardCommand extends EntityCommand { - use IsWizardCommand, IsEntityWizardCommand; + use IsEntityWizardCommand, IsWizardCommand; abstract protected function buildFormFieldsForFirstStep(FieldsContainer $formFields): void; } diff --git a/src/EntityList/Commands/Wizards/InstanceWizardCommand.php b/src/EntityList/Commands/Wizards/InstanceWizardCommand.php index 873680619..b266dca7b 100644 --- a/src/EntityList/Commands/Wizards/InstanceWizardCommand.php +++ b/src/EntityList/Commands/Wizards/InstanceWizardCommand.php @@ -31,7 +31,7 @@ public function executeStep(string $step, mixed $instanceId, array $data = []): // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step executeStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } protected function initialData(mixed $instanceId): array diff --git a/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php b/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php index a962f39dc..7a44a14ff 100644 --- a/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php +++ b/src/EntityList/Commands/Wizards/IsEntityWizardCommand.php @@ -29,7 +29,7 @@ public function executeStep(string $step, array $data = []): array // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step executeStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } protected function initialData(): array diff --git a/src/EntityList/Commands/Wizards/IsWizardCommand.php b/src/EntityList/Commands/Wizards/IsWizardCommand.php index af2a98183..6cca67333 100644 --- a/src/EntityList/Commands/Wizards/IsWizardCommand.php +++ b/src/EntityList/Commands/Wizards/IsWizardCommand.php @@ -10,6 +10,7 @@ trait IsWizardCommand { protected ?WizardCommandContext $wizardCommandContext = null; + private string $key; protected function getWizardContext(): WizardCommandContext @@ -17,7 +18,7 @@ protected function getWizardContext(): WizardCommandContext if (! $this->wizardCommandContext) { $this->wizardCommandContext = session()->get(sprintf('CWC.%s.%s', get_class($this), $this->getKey())); if (! $this->wizardCommandContext) { - $this->wizardCommandContext = new WizardCommandContext(); + $this->wizardCommandContext = new WizardCommandContext; } } @@ -80,7 +81,7 @@ protected function buildFormFieldsForStep(string $step, FieldsContainer $formFie // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step buildFormFieldsForStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } public function buildFormLayout(FormLayoutColumn &$column): void @@ -97,11 +98,7 @@ public function buildFormLayout(FormLayoutColumn &$column): void } } - protected function buildFormLayoutForFirstStep(FormLayoutColumn &$column): void - { - } + protected function buildFormLayoutForFirstStep(FormLayoutColumn &$column): void {} - protected function buildFormLayoutForStep(string $step, FormLayoutColumn &$column): void - { - } + protected function buildFormLayoutForStep(string $step, FormLayoutColumn &$column): void {} } diff --git a/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php b/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php index 8d3a4877b..6f50e3790 100644 --- a/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php +++ b/src/EntityList/Commands/Wizards/SingleInstanceWizardCommand.php @@ -31,7 +31,7 @@ public function executeStep(string $step, array $data = []): array // You can either implement this method and test $step (quick for small commands) // or leave this and implement for each step executeStepXXX // where XXX is the camel cased name of your step - throw new SharpMethodNotImplementedException(); + throw new SharpMethodNotImplementedException; } protected function initialSingleData(): array diff --git a/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php b/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php index fd40ce6ac..970f74dc2 100644 --- a/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php +++ b/src/EntityList/Eloquent/SimpleEloquentReorderHandler.php @@ -7,11 +7,10 @@ class SimpleEloquentReorderHandler implements ReorderHandler { protected string $idAttribute = 'id'; + protected string $orderAttribute = 'order'; - public function __construct(private string $modelClassName) - { - } + public function __construct(private string $modelClassName) {} public function setIdAttribute(string $idAttribute): self { diff --git a/src/EntityList/EntityListQueryParams.php b/src/EntityList/EntityListQueryParams.php index 9cc9c5819..a8f849bec 100644 --- a/src/EntityList/EntityListQueryParams.php +++ b/src/EntityList/EntityListQueryParams.php @@ -10,9 +10,13 @@ class EntityListQueryParams use HasFiltersInQuery; protected ?int $page; + protected ?string $search = null; + protected ?string $sortedBy = null; + protected ?string $sortedDir = null; + protected array $specificIds = []; public static function create(): static diff --git a/src/EntityList/Fields/EntityListField.php b/src/EntityList/Fields/EntityListField.php index 356ab6a1d..9932fc139 100644 --- a/src/EntityList/Fields/EntityListField.php +++ b/src/EntityList/Fields/EntityListField.php @@ -5,16 +5,22 @@ class EntityListField { public string $key; + protected string $label = ''; + protected bool $sortable = false; + protected bool $html = true; + protected ?int $width; + protected int|bool|null $widthXs; + protected bool $hideOnXs = false; public static function make(string $key): self { - $instance = new static(); + $instance = new static; $instance->key = $key; return $instance; diff --git a/src/EntityList/Fields/EntityListFieldsLayout.php b/src/EntityList/Fields/EntityListFieldsLayout.php index 6c3b63a88..94f2b8f50 100644 --- a/src/EntityList/Fields/EntityListFieldsLayout.php +++ b/src/EntityList/Fields/EntityListFieldsLayout.php @@ -11,7 +11,7 @@ class EntityListFieldsLayout { protected array $columns = []; - final public function addColumn(string $key, int $size = null): self + final public function addColumn(string $key, ?int $size = null): self { $this->columns[$key] = ($size ?: 'fill'); @@ -25,7 +25,7 @@ final public function getSizeOf(string $key): int|string|null final public function hasColumns(): bool { - return sizeof($this->columns) > 0; + return count($this->columns) > 0; } final public function getColumns(): Collection diff --git a/src/EntityList/Filters/EntityListCheckFilter.php b/src/EntityList/Filters/EntityListCheckFilter.php index dfc5a84cf..d7b5c295c 100644 --- a/src/EntityList/Filters/EntityListCheckFilter.php +++ b/src/EntityList/Filters/EntityListCheckFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\CheckFilter; -class EntityListCheckFilter extends CheckFilter -{ -} +class EntityListCheckFilter extends CheckFilter {} diff --git a/src/EntityList/Filters/EntityListDateRangeFilter.php b/src/EntityList/Filters/EntityListDateRangeFilter.php index f84452876..9df30d667 100644 --- a/src/EntityList/Filters/EntityListDateRangeFilter.php +++ b/src/EntityList/Filters/EntityListDateRangeFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeFilter; -abstract class EntityListDateRangeFilter extends DateRangeFilter -{ -} +abstract class EntityListDateRangeFilter extends DateRangeFilter {} diff --git a/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php b/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php index 3d32b2135..8513993bd 100644 --- a/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php +++ b/src/EntityList/Filters/EntityListDateRangeRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\DateRangeRequiredFilter; -abstract class EntityListDateRangeRequiredFilter extends DateRangeRequiredFilter -{ -} +abstract class EntityListDateRangeRequiredFilter extends DateRangeRequiredFilter {} diff --git a/src/EntityList/Filters/EntityListSelectFilter.php b/src/EntityList/Filters/EntityListSelectFilter.php index 5b1f461fb..4defd6b4b 100644 --- a/src/EntityList/Filters/EntityListSelectFilter.php +++ b/src/EntityList/Filters/EntityListSelectFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectFilter; -abstract class EntityListSelectFilter extends SelectFilter -{ -} +abstract class EntityListSelectFilter extends SelectFilter {} diff --git a/src/EntityList/Filters/EntityListSelectMultipleFilter.php b/src/EntityList/Filters/EntityListSelectMultipleFilter.php index 652e88adf..33b7b7261 100644 --- a/src/EntityList/Filters/EntityListSelectMultipleFilter.php +++ b/src/EntityList/Filters/EntityListSelectMultipleFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectMultipleFilter; -abstract class EntityListSelectMultipleFilter extends SelectMultipleFilter -{ -} +abstract class EntityListSelectMultipleFilter extends SelectMultipleFilter {} diff --git a/src/EntityList/Filters/EntityListSelectRequiredFilter.php b/src/EntityList/Filters/EntityListSelectRequiredFilter.php index fe4b89019..698f93313 100644 --- a/src/EntityList/Filters/EntityListSelectRequiredFilter.php +++ b/src/EntityList/Filters/EntityListSelectRequiredFilter.php @@ -4,6 +4,4 @@ use Code16\Sharp\Utils\Filters\SelectRequiredFilter; -abstract class EntityListSelectRequiredFilter extends SelectRequiredFilter -{ -} +abstract class EntityListSelectRequiredFilter extends SelectRequiredFilter {} diff --git a/src/EntityList/SharpEntityList.php b/src/EntityList/SharpEntityList.php index 95b26a05a..e35b1a517 100644 --- a/src/EntityList/SharpEntityList.php +++ b/src/EntityList/SharpEntityList.php @@ -17,25 +17,37 @@ abstract class SharpEntityList { - use HandleFilters, + use HandleEntityCommands, HandleEntityState, - HandleEntityCommands, + HandleFilters, HandleInstanceCommands, HandlePageAlertMessage, WithCustomTransformers; private ?EntityListFieldsContainer $fieldsContainer = null; + private ?EntityListFieldsLayout $fieldsLayout = null; + private ?EntityListFieldsLayout $xsFieldsLayout = null; + protected ?EntityListQueryParams $queryParams; + protected string $instanceIdAttribute = 'id'; + protected ?string $multiformAttribute = null; + protected bool $searchable = false; + protected bool $paginated = false; + protected ?ReorderHandler $reorderHandler = null; + protected ?string $defaultSort = null; + protected ?string $defaultSortDir = null; + protected bool $deleteHidden = false; + protected ?string $deleteConfirmationText = null; final public function initQueryParams(): self @@ -222,7 +234,7 @@ final public function reorderHandler(): ?ReorderHandler private function checkListIsBuilt(): void { if ($this->fieldsContainer === null) { - $this->fieldsContainer = new EntityListFieldsContainer(); + $this->fieldsContainer = new EntityListFieldsContainer; $this->buildList($this->fieldsContainer); } } @@ -237,9 +249,7 @@ final protected function getDataKeys(): array /** * Build list config. */ - public function buildListConfig(): void - { - } + public function buildListConfig(): void {} /** * Return all entity commands in an array of class names or instances. @@ -277,9 +287,7 @@ protected function getGlobalMessageData(): ?array * Delete the given instance. Do not implement this method if you want to delegate * the deletion responsibility to the Show Page (then implement it there). */ - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} /** * Retrieve all rows data as an array. @@ -293,12 +301,12 @@ protected function buildList(EntityListFieldsContainer $fields): void { // This default implementation is there to avoid breaking changes; // it will be removed in the next major version of Sharp. - $this->fieldsContainer = new EntityListFieldsContainer(); + $this->fieldsContainer = new EntityListFieldsContainer; $this->buildListFields($this->fieldsContainer); - $fieldsLayout = new EntityListFieldsLayout(); + $fieldsLayout = new EntityListFieldsLayout; $this->buildListLayout($fieldsLayout); - $xsFieldsLayout = new EntityListFieldsLayout(); + $xsFieldsLayout = new EntityListFieldsLayout; $this->buildListLayoutForSmallScreens($xsFieldsLayout); $this->fieldsContainer @@ -332,25 +340,19 @@ protected function buildList(EntityListFieldsContainer $fields): void * * @deprecated use buildList instead */ - protected function buildListFields(EntityListFieldsContainer $fieldsContainer): void - { - } + protected function buildListFields(EntityListFieldsContainer $fieldsContainer): void {} /** * Build list layout. * * @deprecated use buildList instead */ - protected function buildListLayout(EntityListFieldsLayout $fieldsLayout): void - { - } + protected function buildListLayout(EntityListFieldsLayout $fieldsLayout): void {} /** * Build layout for small screen. Optional, only if needed. * * @deprecated use buildList instead */ - protected function buildListLayoutForSmallScreens(EntityListFieldsLayout $fieldsLayout): void - { - } + protected function buildListLayoutForSmallScreens(EntityListFieldsLayout $fieldsLayout): void {} } diff --git a/src/EntityList/Traits/HandleEntityCommands.php b/src/EntityList/Traits/HandleEntityCommands.php index 87a56e91a..b3b7fe22a 100644 --- a/src/EntityList/Traits/HandleEntityCommands.php +++ b/src/EntityList/Traits/HandleEntityCommands.php @@ -10,6 +10,7 @@ trait HandleEntityCommands { protected ?Collection $entityCommandHandlers = null; + protected ?string $primaryEntityCommandKey = null; protected function configurePrimaryEntityCommand(string $commandKeyOrClassName): self diff --git a/src/EntityList/Traits/HandleEntityState.php b/src/EntityList/Traits/HandleEntityState.php index db9261544..94c455b19 100644 --- a/src/EntityList/Traits/HandleEntityState.php +++ b/src/EntityList/Traits/HandleEntityState.php @@ -7,6 +7,7 @@ trait HandleEntityState { protected ?string $entityStateAttribute = null; + protected ?EntityState $entityStateHandler = null; protected function configureEntityState(string $stateAttribute, $stateHandlerOrClassName): self diff --git a/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php b/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php index fb57b41eb..350bf081e 100644 --- a/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php +++ b/src/Exceptions/Auth/SharpAuthenticationNeeds2faException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpAuthenticationNeeds2faException extends SharpException -{ -} +class SharpAuthenticationNeeds2faException extends SharpException {} diff --git a/src/Exceptions/Auth/SharpAuthorizationException.php b/src/Exceptions/Auth/SharpAuthorizationException.php index 262db896a..ee7872804 100644 --- a/src/Exceptions/Auth/SharpAuthorizationException.php +++ b/src/Exceptions/Auth/SharpAuthorizationException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpAuthorizationException extends SharpException -{ -} +class SharpAuthorizationException extends SharpException {} diff --git a/src/Exceptions/Commands/SharpInvalidStepException.php b/src/Exceptions/Commands/SharpInvalidStepException.php index ede046367..ceac26f64 100644 --- a/src/Exceptions/Commands/SharpInvalidStepException.php +++ b/src/Exceptions/Commands/SharpInvalidStepException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpInvalidStepException extends SharpException -{ -} +class SharpInvalidStepException extends SharpException {} diff --git a/src/Exceptions/EntityList/SharpEntityListLayoutException.php b/src/Exceptions/EntityList/SharpEntityListLayoutException.php index 0366ea2d1..0e4f8ca86 100644 --- a/src/Exceptions/EntityList/SharpEntityListLayoutException.php +++ b/src/Exceptions/EntityList/SharpEntityListLayoutException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpEntityListLayoutException extends SharpException -{ -} +class SharpEntityListLayoutException extends SharpException {} diff --git a/src/Exceptions/EntityList/SharpInvalidEntityStateException.php b/src/Exceptions/EntityList/SharpInvalidEntityStateException.php index 3d51f095c..8c5e39958 100644 --- a/src/Exceptions/EntityList/SharpInvalidEntityStateException.php +++ b/src/Exceptions/EntityList/SharpInvalidEntityStateException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpInvalidEntityStateException extends SharpException -{ -} +class SharpInvalidEntityStateException extends SharpException {} diff --git a/src/Exceptions/Form/SharpApplicativeException.php b/src/Exceptions/Form/SharpApplicativeException.php index 644000683..3fd050967 100644 --- a/src/Exceptions/Form/SharpApplicativeException.php +++ b/src/Exceptions/Form/SharpApplicativeException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpApplicativeException extends SharpException -{ -} +class SharpApplicativeException extends SharpException {} diff --git a/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php b/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php index e4da371b0..2ecc81ed6 100644 --- a/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php +++ b/src/Exceptions/Form/SharpFormFieldFormattingMustBeDelayedException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpFormFieldFormattingMustBeDelayedException extends SharpException -{ -} +class SharpFormFieldFormattingMustBeDelayedException extends SharpException {} diff --git a/src/Exceptions/Form/SharpFormUpdateException.php b/src/Exceptions/Form/SharpFormUpdateException.php index 4c8ddd32b..0c948fa97 100644 --- a/src/Exceptions/Form/SharpFormUpdateException.php +++ b/src/Exceptions/Form/SharpFormUpdateException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpFormUpdateException extends SharpException -{ -} +class SharpFormUpdateException extends SharpException {} diff --git a/src/Exceptions/SharpException.php b/src/Exceptions/SharpException.php index 98fad27a3..8db6d41b0 100644 --- a/src/Exceptions/SharpException.php +++ b/src/Exceptions/SharpException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpException extends \Exception -{ -} +class SharpException extends \Exception {} diff --git a/src/Exceptions/SharpInvalidBreadcrumbItemException.php b/src/Exceptions/SharpInvalidBreadcrumbItemException.php index cc8b0e020..3e2f36b20 100644 --- a/src/Exceptions/SharpInvalidBreadcrumbItemException.php +++ b/src/Exceptions/SharpInvalidBreadcrumbItemException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpInvalidBreadcrumbItemException extends SharpException -{ -} +class SharpInvalidBreadcrumbItemException extends SharpException {} diff --git a/src/Exceptions/SharpInvalidConfigException.php b/src/Exceptions/SharpInvalidConfigException.php index 861491f4e..ac20e5c50 100644 --- a/src/Exceptions/SharpInvalidConfigException.php +++ b/src/Exceptions/SharpInvalidConfigException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpInvalidConfigException extends SharpException -{ -} +class SharpInvalidConfigException extends SharpException {} diff --git a/src/Exceptions/SharpInvalidEntityKeyException.php b/src/Exceptions/SharpInvalidEntityKeyException.php index 7ea084879..ba3f5c264 100644 --- a/src/Exceptions/SharpInvalidEntityKeyException.php +++ b/src/Exceptions/SharpInvalidEntityKeyException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpInvalidEntityKeyException extends SharpException -{ -} +class SharpInvalidEntityKeyException extends SharpException {} diff --git a/src/Exceptions/SharpMethodNotImplementedException.php b/src/Exceptions/SharpMethodNotImplementedException.php index 67a574d57..fabd98dbd 100644 --- a/src/Exceptions/SharpMethodNotImplementedException.php +++ b/src/Exceptions/SharpMethodNotImplementedException.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Exceptions; -class SharpMethodNotImplementedException extends SharpException -{ -} +class SharpMethodNotImplementedException extends SharpException {} diff --git a/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php b/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php index 62df10a8d..cb494d2e6 100644 --- a/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php +++ b/src/Exceptions/View/SharpInvalidAssetRenderStrategy.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpInvalidAssetRenderStrategy extends SharpException -{ -} +class SharpInvalidAssetRenderStrategy extends SharpException {} diff --git a/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php b/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php index 9905b6c75..72abc1c90 100644 --- a/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php +++ b/src/Form/Eloquent/Exceptions/SharpFormEloquentUpdateException.php @@ -4,6 +4,4 @@ use Code16\Sharp\Exceptions\SharpException; -class SharpFormEloquentUpdateException extends SharpException -{ -} +class SharpFormEloquentUpdateException extends SharpException {} diff --git a/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php b/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php index 7a80a2331..7ea97f6b8 100644 --- a/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php +++ b/src/Form/Eloquent/Relationships/MorphManyRelationUpdater.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Eloquent\Relationships; -class MorphManyRelationUpdater extends HasManyRelationUpdater -{ -} +class MorphManyRelationUpdater extends HasManyRelationUpdater {} diff --git a/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php b/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php index 112267840..df4ece496 100644 --- a/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php +++ b/src/Form/Eloquent/Relationships/MorphOneRelationUpdater.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Eloquent\Relationships; -class MorphOneRelationUpdater extends HasOneRelationUpdater -{ -} +class MorphOneRelationUpdater extends HasOneRelationUpdater {} diff --git a/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php b/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php index 5a25b70f3..6c885e6cb 100644 --- a/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php +++ b/src/Form/Eloquent/Relationships/MorphToManyRelationUpdater.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Eloquent\Relationships; -class MorphToManyRelationUpdater extends BelongsToManyRelationUpdater -{ -} +class MorphToManyRelationUpdater extends BelongsToManyRelationUpdater {} diff --git a/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php b/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php index 395ffc4aa..29008f33c 100644 --- a/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php +++ b/src/Form/Eloquent/Uploads/Migration/CreateUploadsMigration.php @@ -29,9 +29,6 @@ class CreateUploadsMigration extends Command /** * Create a new migration install command instance. - * - * @param UploadsMigrationCreator $creator - * @param Composer $composer */ public function __construct(UploadsMigrationCreator $creator, Composer $composer) { diff --git a/src/Form/Eloquent/Uploads/SharpUploadModel.php b/src/Form/Eloquent/Uploads/SharpUploadModel.php index d74bffdce..a93e24fbd 100644 --- a/src/Form/Eloquent/Uploads/SharpUploadModel.php +++ b/src/Form/Eloquent/Uploads/SharpUploadModel.php @@ -9,6 +9,7 @@ class SharpUploadModel extends Model { protected $guarded = []; + protected $casts = [ 'custom_properties' => 'array', 'size' => 'integer', @@ -73,7 +74,7 @@ protected function isRealAttribute(string $name): bool ]); } - public function thumbnail(int $width = null, int $height = null, array $customFilters = []): ?string + public function thumbnail(?int $width = null, ?int $height = null, array $customFilters = []): ?string { return (new Thumbnail($this)) ->setTransformationFilters($this->filters ?: null) diff --git a/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php b/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php index 46015ddba..8994e0f0b 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/GreyscaleFilter.php @@ -12,6 +12,6 @@ class GreyscaleFilter extends ThumbnailFilter public function applyFilter(Image $image) { return (new GreyscaleModifier($this->params)) - ->apply($image); + ->apply($image); } } diff --git a/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php b/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php index 35155051b..3e141977f 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/Thumbnail.php @@ -15,14 +15,20 @@ class Thumbnail { protected ImageManager $imageManager; + protected FilesystemManager $storage; + protected SharpUploadModel $uploadModel; + protected int $quality = 90; + protected bool $appendTimestamp = false; + protected ?Closure $afterClosure = null; + protected ?array $transformationFilters = null; - public function __construct(SharpUploadModel $model, ImageManager $imageManager = null, FilesystemManager $storage = null) + public function __construct(SharpUploadModel $model, ?ImageManager $imageManager = null, ?FilesystemManager $storage = null) { $this->uploadModel = $model; $this->imageManager = $imageManager ?: app(ImageManager::class); @@ -50,7 +56,7 @@ public function setAppendTimestamp(bool $appendTimestamp = true): self return $this; } - public function setTransformationFilters(array $transformationFilters = null): self + public function setTransformationFilters(?array $transformationFilters = null): self { $this->transformationFilters = $transformationFilters; @@ -66,7 +72,7 @@ public function make(?int $width, ?int $height = null, array $filters = []): ?st $thumbnailDisk = $this->storage->disk(config('sharp.uploads.thumbnails_disk', 'public')); $thumbDirNameAppender = ($this->transformationFilters ? '_'.md5(serialize($this->transformationFilters)) : '') - .(sizeof($filters) ? '_'.md5(serialize($filters)) : '') + .(count($filters) ? '_'.md5(serialize($filters)) : '') ."_q-$this->quality"; $thumbnailPath = sprintf( diff --git a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php index c34b97aa0..88c7ac268 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailFilter.php @@ -9,9 +9,7 @@ */ abstract class ThumbnailFilter { - public function __construct(protected array $params) - { - } + public function __construct(protected array $params) {} public function resized() { diff --git a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php index 07cfbd593..b861d2664 100644 --- a/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php +++ b/src/Form/Eloquent/Uploads/Thumbnails/ThumbnailModifier.php @@ -6,9 +6,7 @@ abstract class ThumbnailModifier implements ModifierInterface { - public function __construct(protected array $params) - { - } + public function __construct(protected array $params) {} public function resized(): bool { diff --git a/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php b/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php index f53690c80..38ff01160 100644 --- a/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php +++ b/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php @@ -15,8 +15,11 @@ class SharpUploadModelFormAttributeTransformer implements SharpAttributeTransfor use UsesSharpUploadModel; protected bool $withThumbnails; + protected int $thumbnailWidth; + protected int $thumbnailHeight; + private bool $dynamicSharpUploadModel = false; public function __construct(bool $withThumbnails = true, int $thumbnailWidth = 200, int $thumbnailHeight = 200) @@ -36,8 +39,6 @@ public function dynamicInstance(): self /** * Transform a model attribute to array (json-able). * - * @param $value - * @param $instance * @param string $attribute * @return mixed */ diff --git a/src/Form/Fields/Embeds/SharpFormEditorEmbed.php b/src/Form/Fields/Embeds/SharpFormEditorEmbed.php index 341407cea..f4764dc7f 100644 --- a/src/Form/Fields/Embeds/SharpFormEditorEmbed.php +++ b/src/Form/Fields/Embeds/SharpFormEditorEmbed.php @@ -15,11 +15,13 @@ abstract class SharpFormEditorEmbed { use HandleFields, HandlePageAlertMessage, - WithCustomTransformers, - HandleValidation; + HandleValidation, + WithCustomTransformers; protected ?string $label = null; + protected ?string $tagName = null; + protected array $templates = []; public function toConfigArray(bool $isForm): array @@ -50,9 +52,7 @@ public function toConfigArray(bool $isForm): array return $config; } - public function buildEmbedConfig(): void - { - } + public function buildEmbedConfig(): void {} /** * Must return all the data needed by the templates. @@ -81,9 +81,7 @@ abstract public function updateContent(array $data = []): array; /** * Build the optional Embed form layout. */ - public function buildFormLayout(FormLayoutColumn &$column): void - { - } + public function buildFormLayout(FormLayoutColumn &$column): void {} final public function formLayout(): ?array { diff --git a/src/Form/Fields/Formatters/AbstractSimpleFormatter.php b/src/Form/Fields/Formatters/AbstractSimpleFormatter.php index 0044a322f..61eddc5c9 100644 --- a/src/Form/Fields/Formatters/AbstractSimpleFormatter.php +++ b/src/Form/Fields/Formatters/AbstractSimpleFormatter.php @@ -7,8 +7,6 @@ abstract class AbstractSimpleFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/AutocompleteFormatter.php b/src/Form/Fields/Formatters/AutocompleteFormatter.php index 56667a497..d0ff4ecad 100644 --- a/src/Form/Fields/Formatters/AutocompleteFormatter.php +++ b/src/Form/Fields/Formatters/AutocompleteFormatter.php @@ -8,8 +8,6 @@ class AutocompleteFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -22,9 +20,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/AutocompleteListFormatter.php b/src/Form/Fields/Formatters/AutocompleteListFormatter.php index 07e3a2406..88a96fd2e 100644 --- a/src/Form/Fields/Formatters/AutocompleteListFormatter.php +++ b/src/Form/Fields/Formatters/AutocompleteListFormatter.php @@ -7,8 +7,6 @@ class AutocompleteListFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -28,9 +26,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return array */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/CheckFormatter.php b/src/Form/Fields/Formatters/CheckFormatter.php index ef18d6bfd..426c68d02 100644 --- a/src/Form/Fields/Formatters/CheckFormatter.php +++ b/src/Form/Fields/Formatters/CheckFormatter.php @@ -7,8 +7,6 @@ class CheckFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return bool */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return bool */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/EditorFormatter.php b/src/Form/Fields/Formatters/EditorFormatter.php index 086e49150..57d53bcff 100644 --- a/src/Form/Fields/Formatters/EditorFormatter.php +++ b/src/Form/Fields/Formatters/EditorFormatter.php @@ -78,7 +78,7 @@ protected function handleUploadedFiles(string $text, array $files, SharpFormFiel protected function getDomDocument(string $content): DOMDocument { - return tap(new DOMDocument(), function (DOMDocument $dom) use ($content) { + return tap(new DOMDocument, function (DOMDocument $dom) use ($content) { $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); @$dom->loadHTML("
$content"); }); diff --git a/src/Form/Fields/Formatters/GeolocationFormatter.php b/src/Form/Fields/Formatters/GeolocationFormatter.php index 7a4a7f469..b5641bf04 100644 --- a/src/Form/Fields/Formatters/GeolocationFormatter.php +++ b/src/Form/Fields/Formatters/GeolocationFormatter.php @@ -7,8 +7,6 @@ class GeolocationFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -25,9 +23,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return string */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/HtmlFormatter.php b/src/Form/Fields/Formatters/HtmlFormatter.php index 36ff20a6d..3e51573d1 100644 --- a/src/Form/Fields/Formatters/HtmlFormatter.php +++ b/src/Form/Fields/Formatters/HtmlFormatter.php @@ -7,8 +7,6 @@ class HtmlFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return null */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/ListFormatter.php b/src/Form/Fields/Formatters/ListFormatter.php index efe006a8f..59577fc28 100644 --- a/src/Form/Fields/Formatters/ListFormatter.php +++ b/src/Form/Fields/Formatters/ListFormatter.php @@ -7,8 +7,6 @@ class ListFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -43,9 +41,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return array */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/NumberFormatter.php b/src/Form/Fields/Formatters/NumberFormatter.php index 7c22740c2..597da57ba 100644 --- a/src/Form/Fields/Formatters/NumberFormatter.php +++ b/src/Form/Fields/Formatters/NumberFormatter.php @@ -7,8 +7,6 @@ class NumberFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -17,9 +15,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/SelectFormatter.php b/src/Form/Fields/Formatters/SelectFormatter.php index c73ee39e9..63c8792e8 100644 --- a/src/Form/Fields/Formatters/SelectFormatter.php +++ b/src/Form/Fields/Formatters/SelectFormatter.php @@ -8,8 +8,6 @@ class SelectFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -33,9 +31,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/SharpFieldFormatter.php b/src/Form/Fields/Formatters/SharpFieldFormatter.php index cd7d6c515..69d74e9e6 100644 --- a/src/Form/Fields/Formatters/SharpFieldFormatter.php +++ b/src/Form/Fields/Formatters/SharpFieldFormatter.php @@ -7,6 +7,7 @@ abstract class SharpFieldFormatter { protected ?string $instanceId = null; + protected ?array $dataLocalizations = null; public function setInstanceId(?string $instanceId): self @@ -24,16 +25,11 @@ public function setDataLocalizations(array $dataLocalizations): self } /** - * @param SharpFormField $field - * @param $value * @return mixed */ abstract public function toFront(SharpFormField $field, $value); /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return mixed */ abstract public function fromFront(SharpFormField $field, string $attribute, $value); diff --git a/src/Form/Fields/Formatters/TagsFormatter.php b/src/Form/Fields/Formatters/TagsFormatter.php index 53fcdbf6a..142b06eeb 100644 --- a/src/Form/Fields/Formatters/TagsFormatter.php +++ b/src/Form/Fields/Formatters/TagsFormatter.php @@ -8,8 +8,6 @@ class TagsFormatter extends SharpFieldFormatter { /** - * @param SharpFormField $field - * @param $value * @return array */ public function toFront(SharpFormField $field, $value) @@ -30,9 +28,6 @@ public function toFront(SharpFormField $field, $value) } /** - * @param SharpFormField $field - * @param string $attribute - * @param $value * @return array */ public function fromFront(SharpFormField $field, string $attribute, $value) diff --git a/src/Form/Fields/Formatters/TextareaFormatter.php b/src/Form/Fields/Formatters/TextareaFormatter.php index 8a1641acf..d76f4ccf1 100644 --- a/src/Form/Fields/Formatters/TextareaFormatter.php +++ b/src/Form/Fields/Formatters/TextareaFormatter.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Form\Fields\Formatters; -class TextareaFormatter extends TextFormatter -{ -} +class TextareaFormatter extends TextFormatter {} diff --git a/src/Form/Fields/Formatters/UploadFormatter.php b/src/Form/Fields/Formatters/UploadFormatter.php index dc7af8edb..df38248ca 100644 --- a/src/Form/Fields/Formatters/UploadFormatter.php +++ b/src/Form/Fields/Formatters/UploadFormatter.php @@ -17,8 +17,11 @@ class UploadFormatter extends SharpFieldFormatter { protected FilesystemManager $filesystem; + protected FileUtil $fileUtil; + protected ImageManager $imageManager; + private bool $alwaysReturnFullObject = false; public function __construct() @@ -36,8 +39,6 @@ public function setAlwaysReturnFullObject(?bool $returnFullObject = true): self } /** - * @param SharpFormField $field - * @param $value * @return mixed */ public function toFront(SharpFormField $field, $value) @@ -133,7 +134,7 @@ protected function getStoragePath(string $fileName, SharpFormUploadField|SharpFo // Well, we need the instance id for the storage path, and we are // in a store() case. Let's delay this formatter, it will be // called again after a first save() on the model. - throw new SharpFormFieldFormattingMustBeDelayedException(); + throw new SharpFormFieldFormattingMustBeDelayedException; } $basePath = str_replace('{id}', $this->instanceId, $basePath); diff --git a/src/Form/Fields/SharpFormAutocompleteField.php b/src/Form/Fields/SharpFormAutocompleteField.php index 968bb53c8..5feca3242 100644 --- a/src/Form/Fields/SharpFormAutocompleteField.php +++ b/src/Form/Fields/SharpFormAutocompleteField.php @@ -11,32 +11,41 @@ class SharpFormAutocompleteField extends SharpFormField { - use SharpFormFieldWithPlaceholder, SharpFormFieldWithTemplates, - SharpFormFieldWithOptions, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithOptions, + SharpFormFieldWithPlaceholder, SharpFormFieldWithTemplates; const FIELD_TYPE = 'autocomplete'; protected string $mode; + /** @var Collection|array */ protected $localValues = []; + protected array $localSearchKeys = ['value']; + protected string $remoteMethod = 'GET'; + protected ?string $remoteEndpoint = null; + protected string $remoteSearchAttribute = 'query'; + protected string $itemIdAttribute = 'id'; + protected int $searchMinChars = 1; + protected ?array $dynamicAttributes = null; + protected string $dataWrapper = ''; + protected int $debounceDelay = 300; /** - * @param string $key * @param string $mode "local" or "remote" * @return static */ public static function make(string $key, string $mode): self { - $instance = new static($key, static::FIELD_TYPE, new AutocompleteFormatter()); + $instance = new static($key, static::FIELD_TYPE, new AutocompleteFormatter); $instance->mode = $mode; return $instance; diff --git a/src/Form/Fields/SharpFormDateField.php b/src/Form/Fields/SharpFormDateField.php index 226916c39..91f6424e8 100644 --- a/src/Form/Fields/SharpFormDateField.php +++ b/src/Form/Fields/SharpFormDateField.php @@ -9,17 +9,24 @@ class SharpFormDateField extends SharpFormField const FIELD_TYPE = 'date'; protected bool $hasDate = true; + protected bool $hasTime = false; + protected bool $mondayFirst = true; + protected string $minTime = '00:00'; + protected string $maxTime = '23:59'; + protected int $stepTime = 30; + protected ?string $displayFormat = null; + protected ?string $language = null; public static function make(string $key): self { - $field = new static($key, static::FIELD_TYPE, new DateFormatter()); + $field = new static($key, static::FIELD_TYPE, new DateFormatter); $field->language = app()->getLocale(); return $field; @@ -72,7 +79,7 @@ public function setStepTime(int $step): self return $this; } - public function setDisplayFormat(string $displayFormat = null): self + public function setDisplayFormat(?string $displayFormat = null): self { $this->displayFormat = $displayFormat; diff --git a/src/Form/Fields/SharpFormEditorField.php b/src/Form/Fields/SharpFormEditorField.php index ff44baa08..00240ebc9 100644 --- a/src/Form/Fields/SharpFormEditorField.php +++ b/src/Form/Fields/SharpFormEditorField.php @@ -11,42 +11,66 @@ class SharpFormEditorField extends SharpFormField { - use SharpFormFieldWithPlaceholder; - use SharpFormFieldWithUpload; use SharpFormFieldWithDataLocalization; use SharpFormFieldWithEmbeds; use SharpFormFieldWithMaxLength { setMaxLength as protected parentSetMaxLength; } + use SharpFormFieldWithPlaceholder; + use SharpFormFieldWithUpload; const FIELD_TYPE = 'editor'; const B = 'bold'; + const I = 'italic'; + const HIGHLIGHT = 'highlight'; + const SMALL = 'small'; + const UL = 'bullet-list'; + const OL = 'ordered-list'; + const SEPARATOR = '|'; + const A = 'link'; + const H1 = 'heading-1'; + const H2 = 'heading-2'; + const H3 = 'heading-3'; + const CODE = 'code'; + const QUOTE = 'blockquote'; + const UPLOAD_IMAGE = 'upload-image'; + const UPLOAD = 'upload'; + const HR = 'horizontal-rule'; + const TABLE = 'table'; + const IFRAME = 'iframe'; + const RAW_HTML = 'html'; + const CODE_BLOCK = 'code-block'; + const SUP = 'superscript'; + const UNDO = 'undo'; + const REDO = 'redo'; protected int $minHeight = 200; + protected ?int $maxHeight = null; + protected array $toolbar = [ self::B, self::I, self::SEPARATOR, @@ -54,17 +78,21 @@ class SharpFormEditorField extends SharpFormField self::SEPARATOR, self::A, ]; + protected bool $showToolbar = true; + protected bool $renderAsMarkdown = false; + protected bool $withoutParagraphs = false; + protected bool $showCharacterCount = false; public static function make(string $key): self { - return new static($key, static::FIELD_TYPE, new EditorFormatter()); + return new static($key, static::FIELD_TYPE, new EditorFormatter); } - public function setHeight(int $height, int|null $maxHeight = null): self + public function setHeight(int $height, ?int $maxHeight = null): self { $this->minHeight = $height; // Spec maxHeight: diff --git a/src/Form/Fields/SharpFormField.php b/src/Form/Fields/SharpFormField.php index 703e69b25..c97d7c40e 100644 --- a/src/Form/Fields/SharpFormField.php +++ b/src/Form/Fields/SharpFormField.php @@ -9,16 +9,24 @@ abstract class SharpFormField { public string $key; + protected ?string $label = null; + protected string $type; + protected ?string $helpMessage = null; + protected string $conditionalDisplayOperator = 'and'; + protected array $conditionalDisplayFields = []; + protected ?bool $readOnly = null; + protected ?string $extraStyle = null; + protected ?SharpFieldFormatter $formatter; - protected function __construct(string $key, string $type, SharpFieldFormatter $formatter = null) + protected function __construct(string $key, string $type, ?SharpFieldFormatter $formatter = null) { $this->key = $key; $this->type = $type; @@ -91,8 +99,6 @@ public function setFormatter(SharpFieldFormatter $formatter): self /** * Create the properties array for the field, using parent::buildArray(). - * - * @return array */ abstract public function toArray(): array; @@ -119,7 +125,6 @@ protected function validationRules(): array /** * Throw an exception in case of invalid attribute value. * - * @param array $properties * * @throws SharpFormFieldValidationException */ @@ -166,7 +171,7 @@ protected function buildArray(array $childArray): array private function buildConditionalDisplayArray(): ?array { - if (! sizeof($this->conditionalDisplayFields)) { + if (! count($this->conditionalDisplayFields)) { return null; } diff --git a/src/Form/Fields/SharpFormGeolocationField.php b/src/Form/Fields/SharpFormGeolocationField.php index 59654024f..e2009af66 100644 --- a/src/Form/Fields/SharpFormGeolocationField.php +++ b/src/Form/Fields/SharpFormGeolocationField.php @@ -9,13 +9,21 @@ class SharpFormGeolocationField extends SharpFormField const FIELD_TYPE = 'geolocation'; protected string $displayUnit = 'DMS'; + protected bool $geocoding = false; + protected int $zoomLevel = 10; + protected ?array $boundaries = null; + protected ?array $initialPosition = null; + protected string $mapsProvider = 'gmaps'; + protected string $geocodingProvider = 'gmaps'; + protected array $mapsProviderOptions = []; + protected array $geocodingProviderOptions = []; public static function make(string $key): self diff --git a/src/Form/Fields/SharpFormListField.php b/src/Form/Fields/SharpFormListField.php index 26d532b6f..1bcc04380 100644 --- a/src/Form/Fields/SharpFormListField.php +++ b/src/Form/Fields/SharpFormListField.php @@ -12,15 +12,25 @@ class SharpFormListField extends SharpFormField const FIELD_TYPE = 'list'; protected bool $addable = false; + protected bool $sortable = false; + protected bool $removable = false; + protected string $addText; + protected string $itemIdAttribute = 'id'; + protected ?string $orderAttribute = null; + protected ?int $maxItemCount = null; + protected array $itemFields = []; + protected bool $allowBulkUpload = false; + private ?string $bulkUploadItemFieldKey = null; + private int $bulkUploadFileCountLimit = 10; public static function make(string $key): self @@ -63,7 +73,7 @@ public function setOrderAttribute(string $orderAttribute): self return $this; } - public function setMaxItemCount(int $maxItemCount = null): self + public function setMaxItemCount(?int $maxItemCount = null): self { if ($maxItemCount === null) { return $this->setMaxItemCountUnlimited(); diff --git a/src/Form/Fields/SharpFormNumberField.php b/src/Form/Fields/SharpFormNumberField.php index f8b209d5f..08b206360 100644 --- a/src/Form/Fields/SharpFormNumberField.php +++ b/src/Form/Fields/SharpFormNumberField.php @@ -12,8 +12,11 @@ class SharpFormNumberField extends SharpFormField const FIELD_TYPE = 'number'; protected ?float $min = null; + protected ?float $max = null; + protected float $step = 1; + protected bool $showControls = false; public static function make(string $key): self diff --git a/src/Form/Fields/SharpFormSelectField.php b/src/Form/Fields/SharpFormSelectField.php index c8e05b02c..47278d214 100644 --- a/src/Form/Fields/SharpFormSelectField.php +++ b/src/Form/Fields/SharpFormSelectField.php @@ -8,18 +8,26 @@ class SharpFormSelectField extends SharpFormField { - use SharpFormFieldWithOptions, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithOptions; const FIELD_TYPE = 'select'; protected array $options; + protected bool $multiple = false; + protected bool $clearable = false; + protected ?int $maxSelected = null; + protected string $display = 'list'; + protected string $idAttribute = 'id'; + protected bool $inline = false; + protected bool $showSelectAll = false; + protected ?array $dynamicAttributes = null; public static function make(string $key, array $options): self diff --git a/src/Form/Fields/SharpFormTagsField.php b/src/Form/Fields/SharpFormTagsField.php index ca9d9c0e1..10c43447f 100644 --- a/src/Form/Fields/SharpFormTagsField.php +++ b/src/Form/Fields/SharpFormTagsField.php @@ -12,11 +12,17 @@ class SharpFormTagsField extends SharpFormField const FIELD_TYPE = 'tags'; protected bool $creatable = false; + protected string $createText = 'Create'; + protected ?string $createAttribute = null; + protected string $idAttribute = 'id'; + protected ?int $maxTagCount = null; + protected array $options = []; + protected array $createAdditionalAttributes = []; public static function make(string $key, array $options): self diff --git a/src/Form/Fields/SharpFormTextField.php b/src/Form/Fields/SharpFormTextField.php index 5e145f4c6..c5c8f7bd9 100644 --- a/src/Form/Fields/SharpFormTextField.php +++ b/src/Form/Fields/SharpFormTextField.php @@ -9,7 +9,7 @@ class SharpFormTextField extends SharpFormField { - use SharpFormFieldWithPlaceholder, SharpFormFieldWithMaxLength, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithMaxLength, SharpFormFieldWithPlaceholder; const FIELD_TYPE = 'text'; diff --git a/src/Form/Fields/SharpFormTextareaField.php b/src/Form/Fields/SharpFormTextareaField.php index ce2463119..319eb1a52 100644 --- a/src/Form/Fields/SharpFormTextareaField.php +++ b/src/Form/Fields/SharpFormTextareaField.php @@ -9,7 +9,7 @@ class SharpFormTextareaField extends SharpFormField { - use SharpFormFieldWithPlaceholder, SharpFormFieldWithMaxLength, SharpFormFieldWithDataLocalization; + use SharpFormFieldWithDataLocalization, SharpFormFieldWithMaxLength, SharpFormFieldWithPlaceholder; const FIELD_TYPE = 'textarea'; diff --git a/src/Form/Fields/Utils/SharpFormFieldWithOptions.php b/src/Form/Fields/Utils/SharpFormFieldWithOptions.php index 7eef55462..71a8b08c8 100644 --- a/src/Form/Fields/Utils/SharpFormFieldWithOptions.php +++ b/src/Form/Fields/Utils/SharpFormFieldWithOptions.php @@ -9,12 +9,10 @@ trait SharpFormFieldWithOptions { /** * @param array|Collection $options - * @param string $idAttribute - * @return array */ protected static function formatOptions($options, string $idAttribute = 'id'): array { - if (! sizeof($options)) { + if (! count($options)) { return []; } @@ -37,12 +35,10 @@ protected static function formatOptions($options, string $idAttribute = 'id'): a /** * @param array|Collection $options - * @param int $depth - * @return array */ protected static function formatDynamicOptions(&$options, int $depth): array { - if (! sizeof($options)) { + if (! count($options)) { return []; } diff --git a/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php b/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php index f0a3cf863..ebc671222 100644 --- a/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php +++ b/src/Form/Fields/Utils/SharpFormFieldWithTemplates.php @@ -5,6 +5,7 @@ trait SharpFormFieldWithTemplates { protected array $templates = []; + protected ?array $additionalTemplateData = null; protected function setTemplatePath(string $templatePath, string $key): self diff --git a/src/Form/Fields/Utils/SharpFormFieldWithUpload.php b/src/Form/Fields/Utils/SharpFormFieldWithUpload.php index 8bda8fc57..5b550f072 100644 --- a/src/Form/Fields/Utils/SharpFormFieldWithUpload.php +++ b/src/Form/Fields/Utils/SharpFormFieldWithUpload.php @@ -7,14 +7,23 @@ trait SharpFormFieldWithUpload { protected ?float $maxFileSize = null; + protected ?array $cropRatio = null; + protected ?array $transformableFileTypes = null; + protected string $storageDisk = 'local'; + protected string|Closure $storageBasePath = 'data'; + protected bool $transformable = true; + protected ?bool $transformKeepOriginal = null; + protected bool $compactThumbnail = false; + protected bool $shouldOptimizeImage = false; + protected string|array|null $fileFilter = null; public function setMaxFileSize(float $maxFileSizeInMB): self @@ -24,7 +33,7 @@ public function setMaxFileSize(float $maxFileSizeInMB): self return $this; } - public function setCropRatio(string $ratio = null, ?array $transformableFileTypes = null): self + public function setCropRatio(?string $ratio = null, ?array $transformableFileTypes = null): self { if ($ratio) { $this->cropRatio = explode(':', $ratio); diff --git a/src/Form/Layout/FormLayout.php b/src/Form/Layout/FormLayout.php index 2862b622c..41c92a976 100644 --- a/src/Form/Layout/FormLayout.php +++ b/src/Form/Layout/FormLayout.php @@ -9,9 +9,10 @@ class FormLayout implements HasLayout use Conditionable; protected array $tabs = []; + protected bool $tabbed = true; - final public function addTab(string $label, \Closure $callback = null): self + final public function addTab(string $label, ?\Closure $callback = null): self { $tab = $this->addTabLayout(new FormLayoutTab($label)); @@ -22,7 +23,7 @@ final public function addTab(string $label, \Closure $callback = null): self return $this; } - final public function addColumn(int $size, \Closure $callback = null): self + final public function addColumn(int $size, ?\Closure $callback = null): self { $column = $this ->getLonelyTab() @@ -58,7 +59,7 @@ private function addTabLayout(FormLayoutTab $tab): FormLayoutTab private function getLonelyTab(): FormLayoutTab { - if (! sizeof($this->tabs)) { + if (! count($this->tabs)) { $this->addTabLayout(new FormLayoutTab('one')); } diff --git a/src/Form/Layout/FormLayoutColumn.php b/src/Form/Layout/FormLayoutColumn.php index 55b486c2c..97855e2cc 100644 --- a/src/Form/Layout/FormLayoutColumn.php +++ b/src/Form/Layout/FormLayoutColumn.php @@ -8,7 +8,7 @@ class FormLayoutColumn extends LayoutColumn implements HasLayout { protected array $fieldsets = []; - public function withFieldset(string $name, \Closure $callback = null): self + public function withFieldset(string $name, ?\Closure $callback = null): self { $fieldset = new FormLayoutFieldset($name); diff --git a/src/Form/Layout/FormLayoutTab.php b/src/Form/Layout/FormLayoutTab.php index 68fcba543..457d82a54 100644 --- a/src/Form/Layout/FormLayoutTab.php +++ b/src/Form/Layout/FormLayoutTab.php @@ -5,6 +5,7 @@ class FormLayoutTab implements HasLayout { protected string $title; + protected array $columns = []; public function __construct(string $title) @@ -12,7 +13,7 @@ public function __construct(string $title) $this->title = $title; } - public function addColumn(int $size, \Closure $callback = null): self + public function addColumn(int $size, ?\Closure $callback = null): self { $column = $this->addColumnLayout(new FormLayoutColumn($size)); diff --git a/src/Form/Layout/HasFieldRows.php b/src/Form/Layout/HasFieldRows.php index 45f6ccebb..81b979cd4 100644 --- a/src/Form/Layout/HasFieldRows.php +++ b/src/Form/Layout/HasFieldRows.php @@ -11,7 +11,7 @@ trait HasFieldRows protected array $rows = []; - public function withSingleField(string $fieldKey, \Closure $subLayoutCallback = null): self + public function withSingleField(string $fieldKey, ?\Closure $subLayoutCallback = null): self { $this->addRowLayout([ $this->newLayoutField($fieldKey, $subLayoutCallback), @@ -32,7 +32,7 @@ public function withFields(string ...$fieldKeys): self return $this; } - public function insertSingleFieldAt(int $index, string $fieldKey, \Closure $subLayoutCallback = null): self + public function insertSingleFieldAt(int $index, string $fieldKey, ?\Closure $subLayoutCallback = null): self { $rows = collect($this->rows); $rows->splice($index, 0, [[$this->newLayoutField($fieldKey, $subLayoutCallback)]]); @@ -74,7 +74,7 @@ public function fieldsToArray(): array ]; } - protected function newLayoutField(string $fieldKey, \Closure $subLayoutCallback = null): LayoutField + protected function newLayoutField(string $fieldKey, ?\Closure $subLayoutCallback = null): LayoutField { return new FormLayoutField($fieldKey, $subLayoutCallback); } diff --git a/src/Form/SharpForm.php b/src/Form/SharpForm.php index 554d94452..254a5b425 100644 --- a/src/Form/SharpForm.php +++ b/src/Form/SharpForm.php @@ -14,21 +14,24 @@ abstract class SharpForm { - use WithCustomTransformers, + use HandleCustomBreadcrumb, HandleFormFields, + HandleLocalizedFields, HandlePageAlertMessage, - HandleCustomBreadcrumb, - HandleLocalizedFields; + WithCustomTransformers; protected ?FormLayout $formLayout = null; + protected bool $displayShowPageAfterCreation = false; + protected ?string $deleteConfirmationText = null; + protected ?string $formValidatorClass = null; final public function formLayout(): array { if ($this->formLayout === null) { - $this->formLayout = new FormLayout(); + $this->formLayout = new FormLayout; $this->buildFormLayout($this->formLayout); } @@ -74,7 +77,7 @@ final public function newInstance(): ?array ) ->all(); - return sizeof($data) ? $data : null; + return count($data) ? $data : null; } final public function validateRequest(string $entityKey): void @@ -85,9 +88,7 @@ final public function validateRequest(string $entityKey): void } } - public function buildFormConfig(): void - { - } + public function buildFormConfig(): void {} /** * @deprecated @@ -209,9 +210,7 @@ abstract public function update(mixed $id, array $data); * @deprecated * Use delete() in Show Page or in Entity List. Will be removed in v9. */ - public function delete(mixed $id): void - { - } + public function delete(mixed $id): void {} /** * Build form fields. diff --git a/src/Http/Api/Commands/DashboardCommandController.php b/src/Http/Api/Commands/DashboardCommandController.php index d427db7f1..f288f7fa8 100644 --- a/src/Http/Api/Commands/DashboardCommandController.php +++ b/src/Http/Api/Commands/DashboardCommandController.php @@ -9,7 +9,7 @@ class DashboardCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey) { @@ -47,7 +47,7 @@ protected function getCommandHandler(SharpDashboard $dashboard, string $commandK $handler->buildCommandConfig(); if (! $handler->authorize()) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } $handler->initQueryParams(DashboardQueryParams::create()->fillWithRequest()); diff --git a/src/Http/Api/Commands/EntityListEntityCommandController.php b/src/Http/Api/Commands/EntityListEntityCommandController.php index fe49efbd2..14556ef1a 100644 --- a/src/Http/Api/Commands/EntityListEntityCommandController.php +++ b/src/Http/Api/Commands/EntityListEntityCommandController.php @@ -10,7 +10,7 @@ class EntityListEntityCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey) { @@ -51,7 +51,7 @@ protected function getCommandHandler(SharpEntityList $list, string $commandKey): $commandHandler->initQueryParams(EntityListQueryParams::create()->fillWithRequest()); if (! $commandHandler->authorize()) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $commandHandler; diff --git a/src/Http/Api/Commands/EntityListInstanceCommandController.php b/src/Http/Api/Commands/EntityListInstanceCommandController.php index 3c73bd5ff..db7b310bf 100644 --- a/src/Http/Api/Commands/EntityListInstanceCommandController.php +++ b/src/Http/Api/Commands/EntityListInstanceCommandController.php @@ -6,7 +6,7 @@ class EntityListInstanceCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey, mixed $instanceId) { diff --git a/src/Http/Api/Commands/EntityListInstanceStateController.php b/src/Http/Api/Commands/EntityListInstanceStateController.php index 890331d5b..cef0a39c3 100644 --- a/src/Http/Api/Commands/EntityListInstanceStateController.php +++ b/src/Http/Api/Commands/EntityListInstanceStateController.php @@ -17,7 +17,7 @@ public function update(string $entityKey, mixed $instanceId) if (! $list->entityStateHandler()->authorize() || ! $list->entityStateHandler()->authorizeFor($instanceId)) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $this->returnCommandResult( diff --git a/src/Http/Api/Commands/HandleCommandReturn.php b/src/Http/Api/Commands/HandleCommandReturn.php index 127071dfc..095852b56 100644 --- a/src/Http/Api/Commands/HandleCommandReturn.php +++ b/src/Http/Api/Commands/HandleCommandReturn.php @@ -46,7 +46,7 @@ protected function getInstanceCommandHandler(SharpEntityList|SharpShow $commandC $commandHandler->buildCommandConfig(); if (! $commandHandler->authorize() || ! $commandHandler->authorizeFor($instanceId)) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $commandHandler; diff --git a/src/Http/Api/Commands/ShowInstanceCommandController.php b/src/Http/Api/Commands/ShowInstanceCommandController.php index 9001445d3..397e6adfc 100644 --- a/src/Http/Api/Commands/ShowInstanceCommandController.php +++ b/src/Http/Api/Commands/ShowInstanceCommandController.php @@ -7,7 +7,7 @@ class ShowInstanceCommandController extends ApiController { - use HandleCommandReturn, HandleCommandForm; + use HandleCommandForm, HandleCommandReturn; public function show(string $entityKey, string $commandKey, mixed $instanceId = null) { diff --git a/src/Http/Api/Commands/ShowInstanceStateController.php b/src/Http/Api/Commands/ShowInstanceStateController.php index 8fd46e0f7..1619d0948 100644 --- a/src/Http/Api/Commands/ShowInstanceStateController.php +++ b/src/Http/Api/Commands/ShowInstanceStateController.php @@ -17,7 +17,7 @@ public function update(string $entityKey, mixed $instanceId = null) if (! $stateHandler->authorize() || ! $stateHandler->authorizeFor($instanceId)) { - throw new SharpAuthorizationException(); + throw new SharpAuthorizationException; } return $this->returnCommandResult( diff --git a/src/Http/Api/EntityListController.php b/src/Http/Api/EntityListController.php index ab527efcf..de7648013 100644 --- a/src/Http/Api/EntityListController.php +++ b/src/Http/Api/EntityListController.php @@ -45,7 +45,7 @@ public function update(string $entityKey) ]); } - public function delete(string $entityKey, string $instanceId = null) + public function delete(string $entityKey, ?string $instanceId = null) { sharp_check_ability('delete', $entityKey, $instanceId); diff --git a/src/Http/Api/FormController.php b/src/Http/Api/FormController.php index 21703803d..79c4bd729 100644 --- a/src/Http/Api/FormController.php +++ b/src/Http/Api/FormController.php @@ -7,7 +7,7 @@ class FormController extends ApiController { - public function edit(string $entityKey, string $instanceId = null) + public function edit(string $entityKey, ?string $instanceId = null) { sharp_check_ability( $this->entityManager->entityFor($entityKey)->hasShow() ? 'update' : 'view', @@ -56,7 +56,7 @@ public function create(string $entityKey) ); } - public function update(string $entityKey, string $instanceId = null) + public function update(string $entityKey, ?string $instanceId = null) { sharp_check_ability('update', $entityKey, $instanceId); diff --git a/src/Http/Api/ShowController.php b/src/Http/Api/ShowController.php index 7633fcbb9..1ff474151 100644 --- a/src/Http/Api/ShowController.php +++ b/src/Http/Api/ShowController.php @@ -7,7 +7,7 @@ class ShowController extends ApiController { - public function show(string $entityKey, string $instanceId = null) + public function show(string $entityKey, ?string $instanceId = null) { sharp_check_ability('view', $entityKey, $instanceId); diff --git a/src/Http/Context/CurrentSharpRequest.php b/src/Http/Context/CurrentSharpRequest.php index 9997b1dd8..b09225a8a 100644 --- a/src/Http/Context/CurrentSharpRequest.php +++ b/src/Http/Context/CurrentSharpRequest.php @@ -71,7 +71,7 @@ public function getUrlForBreadcrumb(Collection $breadcrumb): string ); } - public function getUrlOfPreviousBreadcrumbItem(string $type = null): string + public function getUrlOfPreviousBreadcrumbItem(?string $type = null): string { $breadcrumb = $this->breadcrumb()->slice(0, -1); if ($type) { @@ -159,7 +159,7 @@ final public function globalFilterFor(string $handlerClass): array|string|null private function buildBreadcrumb(): void { - $this->breadcrumb = new Collection(); + $this->breadcrumb = new Collection; $segments = $this->getSegmentsFromRequest(); $depth = 0; diff --git a/src/Http/Context/Util/BreadcrumbItem.php b/src/Http/Context/Util/BreadcrumbItem.php index e9c5e3bc9..c35aba6cd 100644 --- a/src/Http/Context/Util/BreadcrumbItem.php +++ b/src/Http/Context/Util/BreadcrumbItem.php @@ -7,8 +7,11 @@ class BreadcrumbItem { public string $type; + public string $key; + public ?string $instance = null; + public int $depth = 0; public function __construct(string $type, string $key) diff --git a/src/Http/LangController.php b/src/Http/LangController.php index 658fbcf10..a1dc1cb46 100644 --- a/src/Http/LangController.php +++ b/src/Http/LangController.php @@ -17,7 +17,7 @@ public function index(Request $request) $lang = $request->has('locale') ? $request->input('locale') : app()->getLocale(); $version = sharp_version(); - $strings = Cache::rememberForever("sharp.lang.$lang.$version.js", function () use($lang) { + $strings = Cache::rememberForever("sharp.lang.$lang.$version.js", function () use ($lang) { $localizationStrings = []; $files = [ 'action_bar', @@ -30,7 +30,7 @@ public function index(Request $request) ]; collect($files) - ->map(function (string $filename) use($lang) { + ->map(function (string $filename) use ($lang) { return collect(trans("sharp-front::$filename", [], $lang)) ->mapWithKeys(function ($value, $key) use ($filename) { return ["$filename.$key" => $value]; diff --git a/src/Http/Middleware/Api/AppendBreadcrumb.php b/src/Http/Middleware/Api/AppendBreadcrumb.php index 57f38ccd0..e63f8255c 100644 --- a/src/Http/Middleware/Api/AppendBreadcrumb.php +++ b/src/Http/Middleware/Api/AppendBreadcrumb.php @@ -18,6 +18,7 @@ class AppendBreadcrumb { protected CurrentSharpRequest $currentSharpRequest; + protected ?object $data = null; public function __construct(CurrentSharpRequest $currentSharpRequest) @@ -49,7 +50,7 @@ protected function addBreadcrumbToJsonResponse(JsonResponse $jsonResponse): Json $item->type, isset($item->instance) ? "{$item->key}/{$item->instance}" : $item->key, ); - $isLeaf = $index === sizeof($breadcrumb) - 1; + $isLeaf = $index === count($breadcrumb) - 1; return [ 'type' => $this->getFrontTypeNameFor($item->type), diff --git a/src/Http/Middleware/Api/AppendInstanceAuthorizations.php b/src/Http/Middleware/Api/AppendInstanceAuthorizations.php index e66abfbd2..72f69d647 100644 --- a/src/Http/Middleware/Api/AppendInstanceAuthorizations.php +++ b/src/Http/Middleware/Api/AppendInstanceAuthorizations.php @@ -12,9 +12,7 @@ */ class AppendInstanceAuthorizations { - public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) - { - } + public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) {} public function handle(Request $request, Closure $next) { diff --git a/src/Http/Middleware/Api/AppendListAuthorizations.php b/src/Http/Middleware/Api/AppendListAuthorizations.php index b98a9000d..9e98b8357 100644 --- a/src/Http/Middleware/Api/AppendListAuthorizations.php +++ b/src/Http/Middleware/Api/AppendListAuthorizations.php @@ -9,9 +9,7 @@ class AppendListAuthorizations { - public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) - { - } + public function __construct(protected SharpAuthorizationManager $sharpAuthorizationManager) {} public function handle(Request $request, Closure $next) { diff --git a/src/Http/Middleware/Api/AppendMultiformInEntityList.php b/src/Http/Middleware/Api/AppendMultiformInEntityList.php index 0c68a98a6..82ad196fc 100644 --- a/src/Http/Middleware/Api/AppendMultiformInEntityList.php +++ b/src/Http/Middleware/Api/AppendMultiformInEntityList.php @@ -10,9 +10,7 @@ class AppendMultiformInEntityList { - public function __construct(protected SharpEntityManager $sharpEntityManager) - { - } + public function __construct(protected SharpEntityManager $sharpEntityManager) {} public function handle(Request $request, Closure $next) { @@ -45,13 +43,13 @@ protected function addMultiformDataToJsonResponse(JsonResponse $jsonResponse): J return [ 'key' => $key, - 'label' => is_array($value) && sizeof($value) > 1 ? $value[1] : $key, + 'label' => is_array($value) && count($value) > 1 ? $value[1] : $key, 'instances' => $instanceIds, ]; }) ->keyBy('key'); - if (sizeof($subFormKeys)) { + if (count($subFormKeys)) { $jsonData->forms = $subFormKeys; $jsonResponse->setData($jsonData); } diff --git a/src/Http/Middleware/Api/AppendNotifications.php b/src/Http/Middleware/Api/AppendNotifications.php index e1decb590..21f14cd98 100644 --- a/src/Http/Middleware/Api/AppendNotifications.php +++ b/src/Http/Middleware/Api/AppendNotifications.php @@ -9,8 +9,6 @@ class AppendNotifications { /** - * @param Request $request - * @param Closure $next * @return JsonResponse */ public function handle(Request $request, Closure $next) diff --git a/src/Http/Middleware/Api/HandleSharpApiErrors.php b/src/Http/Middleware/Api/HandleSharpApiErrors.php index 4cc51be01..b4fdaef16 100644 --- a/src/Http/Middleware/Api/HandleSharpApiErrors.php +++ b/src/Http/Middleware/Api/HandleSharpApiErrors.php @@ -69,7 +69,6 @@ private function getHttpCodeFor($exception) } /** - * @param $response * @return JsonResponse */ protected function handleValidationException($response) diff --git a/src/Http/Middleware/SharpRedirectIfAuthenticated.php b/src/Http/Middleware/SharpRedirectIfAuthenticated.php index ff9d68638..8a1792d00 100644 --- a/src/Http/Middleware/SharpRedirectIfAuthenticated.php +++ b/src/Http/Middleware/SharpRedirectIfAuthenticated.php @@ -10,7 +10,6 @@ class SharpRedirectIfAuthenticated * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next * @param string|null $guard * @return mixed */ diff --git a/src/Http/Requests/LoginRequest.php b/src/Http/Requests/LoginRequest.php index 43656c39d..4851e19fd 100644 --- a/src/Http/Requests/LoginRequest.php +++ b/src/Http/Requests/LoginRequest.php @@ -62,7 +62,7 @@ private function attemptToLogin(bool $remember): bool if ($handler->isEnabledFor($guard->user())) { $handler->setUser($guard->user())->generateCode($remember); - throw new SharpAuthenticationNeeds2faException(); + throw new SharpAuthenticationNeeds2faException; } // 2fa is not enabled for this user, we can proceed with the login diff --git a/src/Search/ResultLink.php b/src/Search/ResultLink.php index aa33c01fb..540990d7f 100644 --- a/src/Search/ResultLink.php +++ b/src/Search/ResultLink.php @@ -10,8 +10,7 @@ public function __construct( protected SharpLinkTo $link, protected string $label, protected ?string $detail = null - ) { - } + ) {} public function toArray(): array { diff --git a/src/Search/SearchResultSet.php b/src/Search/SearchResultSet.php index 21eb4fbf3..7bac7828a 100644 --- a/src/Search/SearchResultSet.php +++ b/src/Search/SearchResultSet.php @@ -7,13 +7,14 @@ class SearchResultSet { protected array $resultLinks = []; + protected ?string $emptyStateLabel = null; + protected array $validationErrors = []; + protected bool $hideWhenEmpty = false; - public function __construct(protected string $label, protected ?string $icon = null) - { - } + public function __construct(protected string $label, protected ?string $icon = null) {} final public function addResultLink(SharpLinkTo $link, string $label, ?string $detail = null): ResultLink { diff --git a/src/Show/Fields/SharpShowEntityListField.php b/src/Show/Fields/SharpShowEntityListField.php index 30e8f0d87..4669f766b 100644 --- a/src/Show/Fields/SharpShowEntityListField.php +++ b/src/Show/Fields/SharpShowEntityListField.php @@ -9,16 +9,24 @@ class SharpShowEntityListField extends SharpShowField const FIELD_TYPE = 'entityList'; protected string $entityListKey; + protected array $hiddenFilters = []; + protected array $hiddenCommands = [ 'entity' => [], 'instance' => [], ]; + protected bool $showEntityState = true; + protected bool $showReorderButton = true; + protected bool $showCreateButton = true; + protected bool $showSearchField = true; + protected bool $showCount = false; + protected ?string $label = null; public static function make(string $key, ?string $entityListKey = null): SharpShowEntityListField @@ -128,7 +136,7 @@ public function toArray(): array 'showSearchField' => $this->showSearchField, 'showCount' => $this->showCount, 'hiddenCommands' => $this->hiddenCommands, - 'hiddenFilters' => sizeof($this->hiddenFilters) + 'hiddenFilters' => count($this->hiddenFilters) ? collect($this->hiddenFilters) ->map(function ($value) { // Filter value can be a Closure diff --git a/src/Show/Fields/SharpShowField.php b/src/Show/Fields/SharpShowField.php index 1b1951b71..e7853ddf8 100644 --- a/src/Show/Fields/SharpShowField.php +++ b/src/Show/Fields/SharpShowField.php @@ -8,7 +8,9 @@ abstract class SharpShowField { public string $key; + protected string $type; + protected bool $emptyVisible = false; protected function __construct(string $key, string $type) @@ -45,7 +47,6 @@ protected function buildArray(array $childArray): array /** * Throw an exception in case of invalid attribute value. * - * @param array $properties * * @throws SharpShowFieldValidationException */ diff --git a/src/Show/Fields/SharpShowFileField.php b/src/Show/Fields/SharpShowFileField.php index 1d4a18c0a..7f973cc60 100644 --- a/src/Show/Fields/SharpShowFileField.php +++ b/src/Show/Fields/SharpShowFileField.php @@ -7,7 +7,9 @@ class SharpShowFileField extends SharpShowField const FIELD_TYPE = 'file'; protected ?string $label = null; + protected string $storageDisk = 'local'; + protected string $storageBasePath = 'data'; public static function make(string $key): SharpShowFileField diff --git a/src/Show/Fields/SharpShowListField.php b/src/Show/Fields/SharpShowListField.php index 8d82ec3aa..420a7c0d4 100644 --- a/src/Show/Fields/SharpShowListField.php +++ b/src/Show/Fields/SharpShowListField.php @@ -7,6 +7,7 @@ class SharpShowListField extends SharpShowField const FIELD_TYPE = 'list'; protected ?string $label = null; + protected array $itemFields = []; public static function make(string $key): SharpShowListField diff --git a/src/Show/Fields/SharpShowTextField.php b/src/Show/Fields/SharpShowTextField.php index be7148449..a1f97a158 100644 --- a/src/Show/Fields/SharpShowTextField.php +++ b/src/Show/Fields/SharpShowTextField.php @@ -13,7 +13,9 @@ class SharpShowTextField extends SharpShowField const FIELD_TYPE = 'text'; protected ?string $label = null; + protected ?int $collapseToWordCount = null; + protected bool $html = true; public static function make(string $key): SharpShowTextField diff --git a/src/Show/Layout/ShowLayout.php b/src/Show/Layout/ShowLayout.php index 3b6d8f131..e6ee169f0 100644 --- a/src/Show/Layout/ShowLayout.php +++ b/src/Show/Layout/ShowLayout.php @@ -11,7 +11,7 @@ class ShowLayout implements HasLayout protected array $sections = []; - final public function addSection(string $label, \Closure $callback = null): self + final public function addSection(string $label, ?\Closure $callback = null): self { $section = new ShowLayoutSection($label); $this->sections[] = $section; diff --git a/src/Show/Layout/ShowLayoutColumn.php b/src/Show/Layout/ShowLayoutColumn.php index 2385016d4..cdfb90e36 100644 --- a/src/Show/Layout/ShowLayoutColumn.php +++ b/src/Show/Layout/ShowLayoutColumn.php @@ -11,11 +11,9 @@ class ShowLayoutColumn extends LayoutColumn implements HasLayout /** * Override HasLayout::newLayoutField. * - * @param string $fieldKey - * @param \Closure|null $subLayoutCallback * @return \Code16\Sharp\Form\Layout\FormLayoutField|ShowLayoutField */ - protected function newLayoutField(string $fieldKey, \Closure $subLayoutCallback = null): LayoutField + protected function newLayoutField(string $fieldKey, ?\Closure $subLayoutCallback = null): LayoutField { return new ShowLayoutField($fieldKey, $subLayoutCallback); } diff --git a/src/Show/Layout/ShowLayoutSection.php b/src/Show/Layout/ShowLayoutSection.php index f8334a077..c148984cb 100644 --- a/src/Show/Layout/ShowLayoutSection.php +++ b/src/Show/Layout/ShowLayoutSection.php @@ -7,8 +7,11 @@ class ShowLayoutSection implements HasLayout { protected ?string $title = null; + protected array $columns = []; + protected bool $collapsable = false; + protected ?string $sectionKey = null; public function __construct(string $title) @@ -16,7 +19,7 @@ public function __construct(string $title) $this->title = $title; } - public function addColumn(int $size, \Closure $callback = null): self + public function addColumn(int $size, ?\Closure $callback = null): self { $column = $this->addColumnLayout(new ShowLayoutColumn($size)); diff --git a/src/Show/SharpShow.php b/src/Show/SharpShow.php index a99648c3e..aea427a48 100644 --- a/src/Show/SharpShow.php +++ b/src/Show/SharpShow.php @@ -15,23 +15,26 @@ abstract class SharpShow { - use WithCustomTransformers, - HandleFields, + use HandleCustomBreadcrumb, HandleEntityState, + HandleFields, HandleInstanceCommands, + HandleLocalizedFields, HandlePageAlertMessage, - HandleCustomBreadcrumb, - HandleLocalizedFields; + WithCustomTransformers; protected ?ShowLayout $showLayout = null; + protected ?string $multiformAttribute = null; + protected ?SharpShowTextField $pageTitleField = null; + protected ?string $deleteConfirmationText = null; final public function showLayout(): array { if ($this->showLayout === null) { - $this->showLayout = new ShowLayout(); + $this->showLayout = new ShowLayout; $this->buildShowLayout($this->showLayout); } diff --git a/src/Utils/Entities/BaseSharpEntity.php b/src/Utils/Entities/BaseSharpEntity.php index 6e91db4be..bd91619b7 100644 --- a/src/Utils/Entities/BaseSharpEntity.php +++ b/src/Utils/Entities/BaseSharpEntity.php @@ -8,8 +8,11 @@ abstract class BaseSharpEntity { protected bool $isDashboard = false; + protected string $entityKey = 'entity'; + protected ?string $policy = null; + protected string $label = 'entity'; final public function setEntityKey(string $entityKey): self @@ -22,7 +25,7 @@ final public function setEntityKey(string $entityKey): self final public function getPolicyOrDefault(): SharpEntityPolicy { if (! $policy = $this->getPolicy()) { - return new SharpEntityPolicy(); + return new SharpEntityPolicy; } if (is_string($policy)) { diff --git a/src/Utils/Entities/SharpDashboardEntity.php b/src/Utils/Entities/SharpDashboardEntity.php index b089ed5cf..94c9a1a4f 100644 --- a/src/Utils/Entities/SharpDashboardEntity.php +++ b/src/Utils/Entities/SharpDashboardEntity.php @@ -8,6 +8,7 @@ abstract class SharpDashboardEntity extends BaseSharpEntity { protected bool $isDashboard = true; + protected ?string $view = null; final public function getViewOrFail(): SharpDashboard diff --git a/src/Utils/Entities/SharpEntity.php b/src/Utils/Entities/SharpEntity.php index 0fde6d15f..294f91c54 100644 --- a/src/Utils/Entities/SharpEntity.php +++ b/src/Utils/Entities/SharpEntity.php @@ -10,9 +10,13 @@ abstract class SharpEntity extends BaseSharpEntity { protected bool $isSingle = false; + protected ?string $list = null; + protected ?string $form = null; + protected ?string $show = null; + protected array $prohibitedActions = []; final public function getListOrFail(): SharpEntityList diff --git a/src/Utils/Entities/SharpEntityManager.php b/src/Utils/Entities/SharpEntityManager.php index 52f28abf4..b3f4c3f1f 100644 --- a/src/Utils/Entities/SharpEntityManager.php +++ b/src/Utils/Entities/SharpEntityManager.php @@ -28,7 +28,7 @@ public function entityFor(string $entityKey): SharpEntity|SharpDashboardEntity if (isset($entity)) { if (! app()->bound($entity)) { app()->singleton($entity, function () use ($entity, $entityKey) { - return (new $entity())->setEntityKey($entityKey); + return (new $entity)->setEntityKey($entityKey); }); } diff --git a/src/Utils/Fields/HandleFields.php b/src/Utils/Fields/HandleFields.php index 8025e0948..23cd9429c 100644 --- a/src/Utils/Fields/HandleFields.php +++ b/src/Utils/Fields/HandleFields.php @@ -8,12 +8,13 @@ trait HandleFields { protected ?FieldsContainer $fieldsContainer = null; + protected bool $formBuilt = false; final public function fieldsContainer(): FieldsContainer { if ($this->fieldsContainer === null) { - $this->fieldsContainer = new FieldsContainer(); + $this->fieldsContainer = new FieldsContainer; } return $this->fieldsContainer; diff --git a/src/Utils/Filters/CheckFilter.php b/src/Utils/Filters/CheckFilter.php index f05fe953c..3a924fe45 100644 --- a/src/Utils/Filters/CheckFilter.php +++ b/src/Utils/Filters/CheckFilter.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Utils\Filters; -abstract class CheckFilter extends Filter -{ -} +abstract class CheckFilter extends Filter {} diff --git a/src/Utils/Filters/DateRangeFilter.php b/src/Utils/Filters/DateRangeFilter.php index 07a5f1a2a..cfbd203f6 100644 --- a/src/Utils/Filters/DateRangeFilter.php +++ b/src/Utils/Filters/DateRangeFilter.php @@ -5,6 +5,7 @@ abstract class DateRangeFilter extends Filter { private string $dateFormat = 'YYYY-MM-DD'; + private bool $isMondayFirst = true; final public function configureDateFormat(string $dateFormat): self diff --git a/src/Utils/Filters/Filter.php b/src/Utils/Filters/Filter.php index 59442f614..aba5172fb 100644 --- a/src/Utils/Filters/Filter.php +++ b/src/Utils/Filters/Filter.php @@ -5,7 +5,9 @@ abstract class Filter { protected ?string $customKey = null; + protected ?string $label = null; + protected bool $retainInSession = false; public function getKey(): string @@ -44,7 +46,5 @@ public function configureRetainInSession(bool $retainInSession = true): self return $this; } - public function buildFilterConfig(): void - { - } + public function buildFilterConfig(): void {} } diff --git a/src/Utils/Filters/HasFiltersInQuery.php b/src/Utils/Filters/HasFiltersInQuery.php index e5cc2ca41..6b2e1353f 100644 --- a/src/Utils/Filters/HasFiltersInQuery.php +++ b/src/Utils/Filters/HasFiltersInQuery.php @@ -53,7 +53,7 @@ public function setDefaultFilters(array $filters): self return $this; } - protected function fillFilterWithRequest(array $query = null): void + protected function fillFilterWithRequest(?array $query = null): void { collect($query) ->filter(function ($value, $name) { diff --git a/src/Utils/Filters/SelectFilter.php b/src/Utils/Filters/SelectFilter.php index 3cec24d93..344e08b21 100644 --- a/src/Utils/Filters/SelectFilter.php +++ b/src/Utils/Filters/SelectFilter.php @@ -5,8 +5,11 @@ abstract class SelectFilter extends Filter { private bool $isMaster = false; + private bool $isSearchable = false; + private array $searchKeys = ['label']; + private string $template = '{{label}}'; final public function isMaster(): bool diff --git a/src/Utils/Filters/SelectMultipleFilter.php b/src/Utils/Filters/SelectMultipleFilter.php index 86bed8cbc..56a7c178a 100644 --- a/src/Utils/Filters/SelectMultipleFilter.php +++ b/src/Utils/Filters/SelectMultipleFilter.php @@ -2,6 +2,4 @@ namespace Code16\Sharp\Utils\Filters; -abstract class SelectMultipleFilter extends SelectFilter -{ -} +abstract class SelectMultipleFilter extends SelectFilter {} diff --git a/src/Utils/Layout/LayoutField.php b/src/Utils/Layout/LayoutField.php index 38bd6d248..eb4e9dbce 100644 --- a/src/Utils/Layout/LayoutField.php +++ b/src/Utils/Layout/LayoutField.php @@ -5,11 +5,14 @@ abstract class LayoutField { protected string $fieldKey; + protected int $size = 12; + protected int $sizeXS = 12; + protected array $itemLayout = []; - public function __construct(string $fieldKey, \Closure $subLayoutCallback = null) + public function __construct(string $fieldKey, ?\Closure $subLayoutCallback = null) { if (strpos($fieldKey, '|')) { [$this->fieldKey, $sizes] = explode('|', $fieldKey); diff --git a/src/Utils/Links/LinkToEntityList.php b/src/Utils/Links/LinkToEntityList.php index 4edd5f312..1d96d11c1 100644 --- a/src/Utils/Links/LinkToEntityList.php +++ b/src/Utils/Links/LinkToEntityList.php @@ -8,9 +8,13 @@ class LinkToEntityList extends SharpLinkTo { protected array $filters = []; + protected ?string $searchText = null; + protected ?string $sortAttribute = null; + protected ?string $sortDir = null; + protected ?array $fullQuerystring = null; public static function make(string $entityKey): self diff --git a/src/Utils/Links/LinkToShowPage.php b/src/Utils/Links/LinkToShowPage.php index 0d307f01e..1b771c6ae 100644 --- a/src/Utils/Links/LinkToShowPage.php +++ b/src/Utils/Links/LinkToShowPage.php @@ -7,6 +7,7 @@ class LinkToShowPage extends SharpLinkTo { protected string $instanceId; + protected BreadcrumbBuilder $breadcrumbBuilder; public static function make(string $entityKey, string $instanceId): self @@ -19,7 +20,7 @@ public static function make(string $entityKey, string $instanceId): self public function withBreadcrumb(Closure $closure): self { - $this->breadcrumbBuilder = $closure(new BreadcrumbBuilder()); + $this->breadcrumbBuilder = $closure(new BreadcrumbBuilder); return $this; } diff --git a/src/Utils/Links/SharpLinkTo.php b/src/Utils/Links/SharpLinkTo.php index 150ffa33f..6369950eb 100644 --- a/src/Utils/Links/SharpLinkTo.php +++ b/src/Utils/Links/SharpLinkTo.php @@ -5,6 +5,7 @@ abstract class SharpLinkTo { protected string $entityKey; + protected string $tooltip = ''; protected function __construct(string $entityKey) diff --git a/src/Utils/Menu/SharpMenu.php b/src/Utils/Menu/SharpMenu.php index f432d94fa..1d604ce03 100644 --- a/src/Utils/Menu/SharpMenu.php +++ b/src/Utils/Menu/SharpMenu.php @@ -10,6 +10,7 @@ abstract class SharpMenu use HasSharpMenuItems; protected ?SharpMenuUserMenu $userMenu = null; + private bool $visible = true; final public function addSection(string $title, Closure $callbackClosure): self @@ -23,7 +24,7 @@ final public function addSection(string $title, Closure $callbackClosure): self final public function setUserMenu(Closure $callbackClosure): self { - $this->userMenu = new SharpMenuUserMenu(); + $this->userMenu = new SharpMenuUserMenu; $callbackClosure($this->userMenu); return $this; diff --git a/src/Utils/Menu/SharpMenuItemLink.php b/src/Utils/Menu/SharpMenuItemLink.php index 0e8516d2d..28a4a8adb 100644 --- a/src/Utils/Menu/SharpMenuItemLink.php +++ b/src/Utils/Menu/SharpMenuItemLink.php @@ -9,12 +9,12 @@ class SharpMenuItemLink extends SharpMenuItem { protected SharpEntity|SharpDashboardEntity|null $entity; + protected ?string $entityKey = null; + protected ?string $url = null; - public function __construct(protected ?string $label, protected ?string $icon) - { - } + public function __construct(protected ?string $label, protected ?string $icon) {} public function setEntity(string $entityKey): self { diff --git a/src/Utils/Menu/SharpMenuItemSection.php b/src/Utils/Menu/SharpMenuItemSection.php index c91d807f2..e71d01144 100644 --- a/src/Utils/Menu/SharpMenuItemSection.php +++ b/src/Utils/Menu/SharpMenuItemSection.php @@ -8,9 +8,7 @@ class SharpMenuItemSection extends SharpMenuItem protected bool $collapsible = true; - public function __construct(protected string $label) - { - } + public function __construct(protected string $label) {} public function getLabel(): string { diff --git a/src/Utils/Menu/SharpMenuItemSeparator.php b/src/Utils/Menu/SharpMenuItemSeparator.php index cf0c34a34..96a8d5d2e 100644 --- a/src/Utils/Menu/SharpMenuItemSeparator.php +++ b/src/Utils/Menu/SharpMenuItemSeparator.php @@ -4,9 +4,7 @@ class SharpMenuItemSeparator extends SharpMenuItem { - public function __construct(protected string $label) - { - } + public function __construct(protected string $label) {} public function getLabel(): string { diff --git a/src/Utils/Traits/HandlePageAlertMessage.php b/src/Utils/Traits/HandlePageAlertMessage.php index 0cb4c9bc6..83c182c35 100644 --- a/src/Utils/Traits/HandlePageAlertMessage.php +++ b/src/Utils/Traits/HandlePageAlertMessage.php @@ -7,16 +7,22 @@ trait HandlePageAlertMessage { protected ?SharpShowHtmlField $pageAlertHtmlField = null; + protected string $pageAlertLevel; protected static string $pageAlertLevelNone = 'none'; + protected static string $pageAlertLevelInfo = 'info'; + protected static string $pageAlertLevelWarning = 'warning'; + protected static string $pageAlertLevelDanger = 'danger'; + protected static string $pageAlertLevelPrimary = 'primary'; + protected static string $pageAlertLevelSecondary = 'secondary'; - protected function configurePageAlert(string $template, string $alertLevel = null, string $fieldKey = null, bool $declareTemplateAsPath = false): self + protected function configurePageAlert(string $template, ?string $alertLevel = null, ?string $fieldKey = null, bool $declareTemplateAsPath = false): self { $this->pageAlertHtmlField = SharpShowHtmlField::make($fieldKey ?: uniqid('f')); $this->pageAlertLevel = $alertLevel ?? static::$pageAlertLevelNone; diff --git a/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php b/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php index 81d257b69..e2069be5d 100644 --- a/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php +++ b/src/Utils/Transformers/Attributes/Eloquent/SharpUploadModelThumbnailUrlTransformer.php @@ -18,8 +18,7 @@ public function __construct( protected ?int $width = null, protected ?int $height = null, protected array $filters = [] - ) { - } + ) {} public function renderAsImageTag(bool $renderAsImageTag = true): self { diff --git a/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php b/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php index 5034718fc..fae03b4d8 100644 --- a/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php +++ b/src/Utils/Transformers/Attributes/MarkdownAttributeTransformer.php @@ -31,8 +31,8 @@ public function apply($value, $instance = null, $attribute = null) 'soft_break' => $this->nl2br ? 'some basic markdown test
\n", - (new MarkdownAttributeTransformer())->apply($object->text, $object, 'text'), + (new MarkdownAttributeTransformer)->apply($object->text, $object, 'text'), ); } }