diff --git a/README.md b/README.md index 360ea1ef..a4978347 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details. ## Security -If you discover any security related issues, please email wh7r.com@gmail.com instead of using the issue tracker. +If you discover any security related issues, please email info@larazeus.com instead of using the issue tracker. ## Credits diff --git a/composer.json b/composer.json index 3a6d7e5c..06d86373 100644 --- a/composer.json +++ b/composer.json @@ -5,11 +5,13 @@ "laravel", "lara-zeus", "bolt", - "bolt", "form", "forms", "generator", - "maker" + "self hosted", + "maker", + "builder", + "filamentphp" ], "homepage": "https://github.com/lara-zeus", "license": "MIT", @@ -17,7 +19,7 @@ "authors": [ { "name": "php coder", - "email": "wh7r.com@gmail.com", + "email": "info@larazeus.com", "role": "Owner" } ], @@ -32,14 +34,14 @@ "require-dev": { "orchestra/testbench": "^6.0 || ^7.0", "laravel/pint": "^1.0", - "nunomaduro/larastan": "^2.0.1", + "nunomaduro/larastan": "^2.6", "pestphp/pest": "^1.21", "pestphp/pest-plugin-laravel": "^1.1", "pestphp/pest-plugin-livewire": "^1.0", "pestphp/pest-plugin-parallel": "^0.3", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-phpunit": "^1.3", "phpunit/phpunit": "^9.5" }, "autoload": { diff --git a/composer.lock b/composer.lock index 749ec4fb..fa340c52 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8196e2b4e1d32b04e3efc8238ca7bbc9", + "content-hash": "6a0018405b05273ff947873d51299b2d", "packages": [ { "name": "akaunting/laravel-money", @@ -1010,16 +1010,16 @@ }, { "name": "filament/filament", - "version": "v2.17.44", + "version": "v2.17.45", "source": { "type": "git", "url": "https://github.com/filamentphp/panels.git", - "reference": "a7658bd50da4b35322f1c1616de4b6abd7a6b7a8" + "reference": "bacf17f6b59fa28ced9e3c51a555e37c7df080e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/panels/zipball/a7658bd50da4b35322f1c1616de4b6abd7a6b7a8", - "reference": "a7658bd50da4b35322f1c1616de4b6abd7a6b7a8", + "url": "https://api.github.com/repos/filamentphp/panels/zipball/bacf17f6b59fa28ced9e3c51a555e37c7df080e8", + "reference": "bacf17f6b59fa28ced9e3c51a555e37c7df080e8", "shasum": "" }, "require": { @@ -1040,7 +1040,6 @@ "illuminate/view": "^8.6|^9.0|^10.0", "livewire/livewire": "^2.10.7", "php": "^8.0", - "ryangjchandler/blade-capture-directive": "^0.2|^0.3", "spatie/laravel-package-tools": "^1.9" }, "type": "library", @@ -1069,20 +1068,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2023-05-30T10:44:54+00:00" + "time": "2023-06-06T11:21:28+00:00" }, { "name": "filament/forms", - "version": "v2.17.44", + "version": "v2.17.45", "source": { "type": "git", "url": "https://github.com/filamentphp/forms.git", - "reference": "c6b5d4f04716f14a4d5f63f76c8b94df8029a17f" + "reference": "b41dc730783813f5622a9bad5f81a767fe94f7af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/forms/zipball/c6b5d4f04716f14a4d5f63f76c8b94df8029a17f", - "reference": "c6b5d4f04716f14a4d5f63f76c8b94df8029a17f", + "url": "https://api.github.com/repos/filamentphp/forms/zipball/b41dc730783813f5622a9bad5f81a767fe94f7af", + "reference": "b41dc730783813f5622a9bad5f81a767fe94f7af", "shasum": "" }, "require": { @@ -1127,20 +1126,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2023-05-30T10:44:57+00:00" + "time": "2023-06-06T11:21:25+00:00" }, { "name": "filament/notifications", - "version": "v2.17.44", + "version": "v2.17.45", "source": { "type": "git", "url": "https://github.com/filamentphp/notifications.git", - "reference": "a9bee8c8b7cdf1df798311acdf57895d73dd3af7" + "reference": "2a0a808bff7b6eb036aa7d652e2167c3b3d7bd29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/notifications/zipball/a9bee8c8b7cdf1df798311acdf57895d73dd3af7", - "reference": "a9bee8c8b7cdf1df798311acdf57895d73dd3af7", + "url": "https://api.github.com/repos/filamentphp/notifications/zipball/2a0a808bff7b6eb036aa7d652e2167c3b3d7bd29", + "reference": "2a0a808bff7b6eb036aa7d652e2167c3b3d7bd29", "shasum": "" }, "require": { @@ -1180,11 +1179,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2023-05-30T10:44:51+00:00" + "time": "2023-06-06T11:21:19+00:00" }, { "name": "filament/spatie-laravel-translatable-plugin", - "version": "v2.17.44", + "version": "v2.17.45", "source": { "type": "git", "url": "https://github.com/filamentphp/spatie-laravel-translatable-plugin.git", @@ -1230,16 +1229,16 @@ }, { "name": "filament/support", - "version": "v2.17.44", + "version": "v2.17.45", "source": { "type": "git", "url": "https://github.com/filamentphp/support.git", - "reference": "fe7434dd07b254de0d9cc7d9178540ad8b087cca" + "reference": "2fc7b60416283c17a7b8ce2f8d65d4d02ed766fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/support/zipball/fe7434dd07b254de0d9cc7d9178540ad8b087cca", - "reference": "fe7434dd07b254de0d9cc7d9178540ad8b087cca", + "url": "https://api.github.com/repos/filamentphp/support/zipball/2fc7b60416283c17a7b8ce2f8d65d4d02ed766fb", + "reference": "2fc7b60416283c17a7b8ce2f8d65d4d02ed766fb", "shasum": "" }, "require": { @@ -1247,6 +1246,7 @@ "illuminate/support": "^8.6|^9.0|^10.0", "illuminate/view": "^8.6|^9.0|^10.0", "php": "^8.0", + "ryangjchandler/blade-capture-directive": "^0.2|^0.3", "spatie/laravel-package-tools": "^1.9", "tgalopin/html-sanitizer": "^1.5" }, @@ -1276,20 +1276,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2023-05-30T10:44:54+00:00" + "time": "2023-06-06T11:21:22+00:00" }, { "name": "filament/tables", - "version": "v2.17.44", + "version": "v2.17.45", "source": { "type": "git", "url": "https://github.com/filamentphp/tables.git", - "reference": "57833d3f09c6ec5fbbabec5a0e47944b972ceaa3" + "reference": "4993ac5c3ceee89f29e97c79a4682899166074ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/tables/zipball/57833d3f09c6ec5fbbabec5a0e47944b972ceaa3", - "reference": "57833d3f09c6ec5fbbabec5a0e47944b972ceaa3", + "url": "https://api.github.com/repos/filamentphp/tables/zipball/4993ac5c3ceee89f29e97c79a4682899166074ac", + "reference": "4993ac5c3ceee89f29e97c79a4682899166074ac", "shasum": "" }, "require": { @@ -1332,7 +1332,7 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2023-05-30T10:44:53+00:00" + "time": "2023-06-06T11:21:20+00:00" }, { "name": "fruitcake/php-cors", @@ -1611,16 +1611,16 @@ }, { "name": "lara-zeus/core", - "version": "2.4.7", + "version": "2.4.8", "source": { "type": "git", "url": "https://github.com/lara-zeus/core.git", - "reference": "b264c114c56e42ee64e8805f3d0017b774526024" + "reference": "1554b95e1f79d781adbb47f6f84a9d5cc2201f6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lara-zeus/core/zipball/b264c114c56e42ee64e8805f3d0017b774526024", - "reference": "b264c114c56e42ee64e8805f3d0017b774526024", + "url": "https://api.github.com/repos/lara-zeus/core/zipball/1554b95e1f79d781adbb47f6f84a9d5cc2201f6f", + "reference": "1554b95e1f79d781adbb47f6f84a9d5cc2201f6f", "shasum": "" }, "require": { @@ -1683,7 +1683,7 @@ ], "support": { "issues": "https://github.com/lara-zeus/core/issues", - "source": "https://github.com/lara-zeus/core/tree/2.4.7" + "source": "https://github.com/lara-zeus/core/tree/2.4.8" }, "funding": [ { @@ -1691,7 +1691,7 @@ "type": "github" } ], - "time": "2023-06-04T21:29:55+00:00" + "time": "2023-06-06T13:45:27+00:00" }, { "name": "laravel/framework", @@ -6957,28 +6957,30 @@ }, { "name": "mockery/mockery", - "version": "1.5.1", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "e92dcc83d5a51851baf5f5591d32cb2b16e3684e" + "reference": "a8dd186f07ea667c1e3abd2176bfab0ab161ea94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/e92dcc83d5a51851baf5f5591d32cb2b16e3684e", - "reference": "e92dcc83d5a51851baf5f5591d32cb2b16e3684e", + "url": "https://api.github.com/repos/mockery/mockery/zipball/a8dd186f07ea667c1e3abd2176bfab0ab161ea94", + "reference": "a8dd186f07ea667c1e3abd2176bfab0ab161ea94", "shasum": "" }, "require": { "hamcrest/hamcrest-php": "^2.0.1", "lib-pcre": ">=7.0", - "php": "^7.3 || ^8.0" + "php": "^7.4 || ^8.0" }, "conflict": { "phpunit/phpunit": "<8.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.3" + "phpunit/phpunit": "^8.5 || ^9.3", + "psalm/plugin-phpunit": "^0.18", + "vimeo/psalm": "^5.9" }, "type": "library", "extra": { @@ -6987,8 +6989,12 @@ } }, "autoload": { - "psr-0": { - "Mockery": "library/" + "files": [ + "library/helpers.php", + "library/Mockery.php" + ], + "psr-4": { + "Mockery\\": "library/Mockery" } }, "notification-url": "https://packagist.org/downloads/", @@ -7023,9 +7029,9 @@ ], "support": { "issues": "https://github.com/mockery/mockery/issues", - "source": "https://github.com/mockery/mockery/tree/1.5.1" + "source": "https://github.com/mockery/mockery/tree/1.6.1" }, - "time": "2022-09-07T15:32:08+00:00" + "time": "2023-06-05T13:59:03+00:00" }, { "name": "myclabs/deep-copy", @@ -7232,16 +7238,16 @@ }, { "name": "nunomaduro/larastan", - "version": "v2.6.0", + "version": "v2.6.1", "source": { "type": "git", "url": "https://github.com/nunomaduro/larastan.git", - "reference": "ccac5b25949576807862cf32ba1fce1769c06c42" + "reference": "7823bc1fdbd8e72fd1e9cd8d746e7e104bccf02c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/larastan/zipball/ccac5b25949576807862cf32ba1fce1769c06c42", - "reference": "ccac5b25949576807862cf32ba1fce1769c06c42", + "url": "https://api.github.com/repos/nunomaduro/larastan/zipball/7823bc1fdbd8e72fd1e9cd8d746e7e104bccf02c", + "reference": "7823bc1fdbd8e72fd1e9cd8d746e7e104bccf02c", "shasum": "" }, "require": { @@ -7304,7 +7310,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/larastan/issues", - "source": "https://github.com/nunomaduro/larastan/tree/v2.6.0" + "source": "https://github.com/nunomaduro/larastan/tree/v2.6.1" }, "funding": [ { @@ -7324,7 +7330,7 @@ "type": "patreon" } ], - "time": "2023-04-20T12:40:01+00:00" + "time": "2023-06-04T20:55:57+00:00" }, { "name": "orchestra/testbench", @@ -7988,16 +7994,16 @@ }, { "name": "phpmyadmin/sql-parser", - "version": "5.7.0", + "version": "5.8.0", "source": { "type": "git", "url": "https://github.com/phpmyadmin/sql-parser.git", - "reference": "0f5895aab2b6002d00b6831b60983523dea30bff" + "reference": "db1b3069b5dbc220d393d67ff911e0ae76732755" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/0f5895aab2b6002d00b6831b60983523dea30bff", - "reference": "0f5895aab2b6002d00b6831b60983523dea30bff", + "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/db1b3069b5dbc220d393d67ff911e0ae76732755", + "reference": "db1b3069b5dbc220d393d67ff911e0ae76732755", "shasum": "" }, "require": { @@ -8071,7 +8077,7 @@ "type": "other" } ], - "time": "2023-01-25T10:43:40+00:00" + "time": "2023-06-05T18:19:38+00:00" }, { "name": "phpstan/extension-installer", @@ -8119,16 +8125,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.15", + "version": "1.10.16", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd" + "reference": "352bdbb960bb523e3d71b834862589f910921c23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/762c4dac4da6f8756eebb80e528c3a47855da9bd", - "reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/352bdbb960bb523e3d71b834862589f910921c23", + "reference": "352bdbb960bb523e3d71b834862589f910921c23", "shasum": "" }, "require": { @@ -8177,7 +8183,7 @@ "type": "tidelift" } ], - "time": "2023-05-09T15:28:01+00:00" + "time": "2023-06-05T08:21:46+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", diff --git a/docs/installation.md b/docs/installation.md index 1f184a62..4843c7d0 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -33,3 +33,7 @@ finally, run the migration: ```bash php artisan migrate ``` + +## Usage + +visit the url `/admin` , and `/forms` to access the forms. diff --git a/src/Fields/Classes/CheckboxList.php b/src/Fields/Classes/CheckboxList.php index 969a4533..5d7e09e4 100644 --- a/src/Fields/Classes/CheckboxList.php +++ b/src/Fields/Classes/CheckboxList.php @@ -42,6 +42,10 @@ public function appendFilamentComponentsOptions($component, $zeusField) { parent::appendFilamentComponentsOptions($component, $zeusField); - return $component->options(collect(config('zeus-bolt.models.Collection')::find($zeusField->options['dataSource'])->values)->pluck('itemValue', 'itemKey')); + $options = collect(optional(config('zeus-bolt.models.Collection')::find($zeusField->options['dataSource']))->values); + + return $component + ->options($options->pluck('itemValue', 'itemKey')) + ->default($options->where('itemIsDefault', true)->pluck('itemKey')); } } diff --git a/src/Fields/Classes/Radio.php b/src/Fields/Classes/Radio.php index b292c1ed..0aca7ab5 100644 --- a/src/Fields/Classes/Radio.php +++ b/src/Fields/Classes/Radio.php @@ -42,7 +42,11 @@ public function appendFilamentComponentsOptions($component, $zeusField) { parent::appendFilamentComponentsOptions($component, $zeusField); - $component = $component->options(collect(config('zeus-bolt.models.Collection')::find($zeusField->options['dataSource'])->values)->pluck('itemValue', 'itemKey')); + $options = collect(optional(config('zeus-bolt.models.Collection')::find($zeusField->options['dataSource']))->values); + $component = $component + ->options($options->pluck('itemValue', 'itemKey')) + ->default($options->where('itemIsDefault', true)->pluck('itemKey')); + if (isset($zeusField->options['is_inline']) && $zeusField->options['is_inline']) { $component->inline(); } diff --git a/src/Fields/Classes/Select.php b/src/Fields/Classes/Select.php index 700a2be2..3ee4a09a 100644 --- a/src/Fields/Classes/Select.php +++ b/src/Fields/Classes/Select.php @@ -20,8 +20,17 @@ public function title(): string public static function getOptions(): array { return [ - FilamentSelect::make('options.dataSource')->required()->options(config('zeus-bolt.models.Collection')::pluck('name', 'id'))->label(__('Data Source'))->columnSpan(2), - Toggle::make('options.is_required')->label(__('Is Required')), + FilamentSelect::make('options.dataSource') + ->required() + ->options(config('zeus-bolt.models.Collection')::pluck('name', 'id')) + ->label(__('Data Source')) + ->columnSpan(2), + Toggle::make('options.is_required') + ->label(__('Is Required')) + ->columnSpan(2), + Toggle::make('options.allow_multiple') + ->label(__('Allow Multiple')) + ->columnSpan(2), \Filament\Forms\Components\TextInput::make('options.htmlId') ->default(str()->random(6)) ->label(__('HTML ID')), @@ -56,8 +65,17 @@ public function appendFilamentComponentsOptions($component, $zeusField) { parent::appendFilamentComponentsOptions($component, $zeusField); - return $component + $options = collect(optional(config('zeus-bolt.models.Collection')::find($zeusField->options['dataSource']))->values); + + $component = $component ->searchable() - ->options(collect(\optional(config('zeus-bolt.models.Collection')::find($zeusField->options['dataSource']))->values)->pluck('itemValue', 'itemKey')); + ->options($options->pluck('itemValue', 'itemKey')) + ->default($options->where('itemIsDefault', true)->pluck('itemKey')); + + if (isset($zeusField->options['allow_multiple']) && $zeusField->options['allow_multiple']) { + $component = $component->multiple(); + } + + return $component; } } diff --git a/src/Fields/Classes/TextInput.php b/src/Fields/Classes/TextInput.php index d3dd56b4..dbb42fb1 100644 --- a/src/Fields/Classes/TextInput.php +++ b/src/Fields/Classes/TextInput.php @@ -34,8 +34,6 @@ public static function getOptions(): array ->default('text') ->reactive(), - Toggle::make('options.is_required')->label(__('Is Required')), - \Filament\Forms\Components\TextInput::make('options.prefix')->label(__('prefix')), \Filament\Forms\Components\TextInput::make('options.suffix')->label(__('suffix')), \Filament\Forms\Components\TextInput::make('options.minValue')->visible(fn (Closure $get): bool => $get('options.dateType') === 'numeric')->label(__('min value')), @@ -43,6 +41,9 @@ public static function getOptions(): array \Filament\Forms\Components\TextInput::make('options.htmlId') ->default(str()->random(6)) ->label(__('HTML ID')), + + Toggle::make('options.is_required')->label(__('Is Required')), + ]; } } diff --git a/src/Filament/Resources/CategoryResource.php b/src/Filament/Resources/CategoryResource.php index ae287666..bac9dedd 100644 --- a/src/Filament/Resources/CategoryResource.php +++ b/src/Filament/Resources/CategoryResource.php @@ -9,6 +9,7 @@ use Filament\Forms\Components\Toggle; use Filament\Resources\Form; use Filament\Resources\Table; +use Filament\Tables\Actions\ActionGroup; use Filament\Tables\Actions\DeleteAction; use Filament\Tables\Actions\DeleteBulkAction; use Filament\Tables\Actions\EditAction; @@ -85,8 +86,10 @@ public static function table(Table $table): Table ->reorderable('ordering') ->defaultSort('id', 'desc') ->actions([ - EditAction::make(), - DeleteAction::make(), + ActionGroup::make([ + EditAction::make(), + DeleteAction::make(), + ]), ]) ->bulkActions([ DeleteBulkAction::make(), diff --git a/src/Filament/Resources/CategoryResource/Pages/ListCategories.php b/src/Filament/Resources/CategoryResource/Pages/ListCategories.php index f7c0cde9..6b7f2ef5 100644 --- a/src/Filament/Resources/CategoryResource/Pages/ListCategories.php +++ b/src/Filament/Resources/CategoryResource/Pages/ListCategories.php @@ -3,17 +3,20 @@ namespace LaraZeus\Bolt\Filament\Resources\CategoryResource\Pages; use Filament\Pages\Actions; -use Filament\Resources\Pages\ManageRecords; +use Filament\Resources\Pages\ListRecords; use LaraZeus\Bolt\Filament\Resources\CategoryResource; use LaraZeus\Bolt\Filament\Resources\FormResource\Widgets\BetaNote; -class ListCategories extends ManageRecords +class ListCategories extends ListRecords { + use ListRecords\Concerns\Translatable; + protected static string $resource = CategoryResource::class; protected function getActions(): array { return [ + Actions\LocaleSwitcher::make(), Actions\CreateAction::make(), ]; } diff --git a/src/Filament/Resources/CollectionResource.php b/src/Filament/Resources/CollectionResource.php index a4f42f48..4d721c11 100644 --- a/src/Filament/Resources/CollectionResource.php +++ b/src/Filament/Resources/CollectionResource.php @@ -7,6 +7,9 @@ use Filament\Forms\Components\Toggle; use Filament\Resources\Form; use Filament\Resources\Table; +use Filament\Tables\Actions\ActionGroup; +use Filament\Tables\Actions\DeleteAction; +use Filament\Tables\Actions\EditAction; use Filament\Tables\Columns\TextColumn; use LaraZeus\Bolt\Filament\Resources\CollectionResource\Pages; @@ -74,6 +77,12 @@ public static function table(Table $table): Table ->columns([ TextColumn::make('name')->label(__('Collections Name'))->searchable(), TextColumn::make('values-list')->html()->label(__('Collections Values'))->searchable(['values']), + ]) + ->actions([ + ActionGroup::make([ + EditAction::make(), + DeleteAction::make(), + ]), ]); } diff --git a/src/Filament/Resources/FormResource.php b/src/Filament/Resources/FormResource.php index c3b6a42a..7c97730d 100644 --- a/src/Filament/Resources/FormResource.php +++ b/src/Filament/Resources/FormResource.php @@ -68,13 +68,13 @@ public static function table(Table $table): Table { return $table ->columns([ - TextColumn::make('name')->searchable()->sortable()->label(__('Form Name')), - TextColumn::make('category.name')->label(__('Category'))->sortable(), - IconColumn::make('is_active')->boolean()->label(__('Is Active'))->sortable(), - TextColumn::make('start_date')->dateTime()->searchable()->sortable()->label(__('Start Date')), - TextColumn::make('end_date')->dateTime()->searchable()->sortable()->label(__('End Date')), - IconColumn::make('responses_exists')->boolean()->exists('responses')->label(__('Responses Exists'))->sortable(), - TextColumn::make('responses_count')->counts('responses')->label(__('Responses Count'))->sortable(), + TextColumn::make('name')->searchable()->sortable()->label(__('Form Name'))->toggleable(), + TextColumn::make('category.name')->label(__('Category'))->sortable()->toggleable(), + IconColumn::make('is_active')->boolean()->label(__('Is Active'))->sortable()->toggleable(), + TextColumn::make('start_date')->dateTime()->searchable()->sortable()->label(__('Start Date'))->toggleable(), + TextColumn::make('end_date')->dateTime()->searchable()->sortable()->label(__('End Date'))->toggleable(), + IconColumn::make('responses_exists')->boolean()->exists('responses')->label(__('Responses Exists'))->sortable()->toggleable(), + TextColumn::make('responses_count')->counts('responses')->label(__('Responses Count'))->sortable()->toggleable(), ]) ->actions([ ActionGroup::make([ diff --git a/src/Filament/Resources/FormResource/Schemata.php b/src/Filament/Resources/FormResource/Schemata.php index 4374c55e..9c84f9cf 100644 --- a/src/Filament/Resources/FormResource/Schemata.php +++ b/src/Filament/Resources/FormResource/Schemata.php @@ -236,6 +236,8 @@ public static function getSectionsSchema(): array ->grid([ 'default' => 1, 'md' => 2, + 'xl' => 3, + '2xl' => 4, ]) ->label('') ->itemLabel(fn (array $state): ?string => $state['name'] ?? null) @@ -271,6 +273,10 @@ public static function getFieldsSchema(): array ->icon('heroicon-o-cog') ->schema([ Grid::make() + ->columns([ + 'default' => 1, + 'lg' => 2, + ]) ->label(__('Field Options')) ->visible(function (Closure $get) { $class = $get('type'); diff --git a/src/Filament/Resources/FormResource/Widgets/FormOverview.php b/src/Filament/Resources/FormResource/Widgets/FormOverview.php index 2c4cbdb8..a561edf4 100644 --- a/src/Filament/Resources/FormResource/Widgets/FormOverview.php +++ b/src/Filament/Resources/FormResource/Widgets/FormOverview.php @@ -4,18 +4,14 @@ use Filament\Widgets\StatsOverviewWidget as BaseWidget; use Filament\Widgets\StatsOverviewWidget\Card; -use Illuminate\Database\Eloquent\Model; +use LaraZeus\Bolt\Models\Form; class FormOverview extends BaseWidget { - public ?Model $record = null; + public Form $record; protected function getCards(): array { - if ($this->record === null) { - return []; - } - return [ Card::make('fields', $this->record->fields()->count())->label(__('Fields')), Card::make('responses', $this->record->responses()->count())->label(__('Responses')), diff --git a/src/Filament/Resources/FormResource/Widgets/ResponsesPerFields.php b/src/Filament/Resources/FormResource/Widgets/ResponsesPerFields.php index 20d52de3..cda00faa 100644 --- a/src/Filament/Resources/FormResource/Widgets/ResponsesPerFields.php +++ b/src/Filament/Resources/FormResource/Widgets/ResponsesPerFields.php @@ -3,12 +3,12 @@ namespace LaraZeus\Bolt\Filament\Resources\FormResource\Widgets; use Filament\Widgets\PieChartWidget; -use Illuminate\Database\Eloquent\Model; use LaraZeus\Bolt\Models\FieldResponse; +use LaraZeus\Bolt\Models\Form; class ResponsesPerFields extends PieChartWidget { - public ?Model $record = null; + public Form $record; protected int|string|array $columnSpan = [ 'sm' => 1, @@ -23,10 +23,7 @@ protected function getHeading(): string protected function getData(): array { - if ($this->record === null) { - return []; - } - + $dataset = []; $fields = $this->record->fields; foreach ($fields as $field) { $dataset[] = FieldResponse::query() diff --git a/src/Filament/Resources/FormResource/Widgets/ResponsesPerMonth.php b/src/Filament/Resources/FormResource/Widgets/ResponsesPerMonth.php index dfe8ed10..5bea209e 100644 --- a/src/Filament/Resources/FormResource/Widgets/ResponsesPerMonth.php +++ b/src/Filament/Resources/FormResource/Widgets/ResponsesPerMonth.php @@ -3,12 +3,12 @@ namespace LaraZeus\Bolt\Filament\Resources\FormResource\Widgets; use Filament\Widgets\LineChartWidget; -use Illuminate\Database\Eloquent\Model; +use LaraZeus\Bolt\Models\Form; use LaraZeus\Bolt\Models\Response; class ResponsesPerMonth extends LineChartWidget { - public ?Model $record = null; + public Form $record; protected int|string|array $columnSpan = 'full'; @@ -21,9 +21,7 @@ protected function getHeading(): string protected function getData(): array { - if ($this->record === null) { - return []; - } + $dataset = []; for ($m = 1; $m <= 12; $m++) { $month = date('m', mktime(0, 0, 0, $m, 1, now()->format('Y'))); diff --git a/src/Filament/Resources/FormResource/Widgets/ResponsesPerStatus.php b/src/Filament/Resources/FormResource/Widgets/ResponsesPerStatus.php index 8940f90d..ec4c7062 100644 --- a/src/Filament/Resources/FormResource/Widgets/ResponsesPerStatus.php +++ b/src/Filament/Resources/FormResource/Widgets/ResponsesPerStatus.php @@ -3,13 +3,13 @@ namespace LaraZeus\Bolt\Filament\Resources\FormResource\Widgets; use Filament\Widgets\PieChartWidget; -use Illuminate\Database\Eloquent\Model; +use LaraZeus\Bolt\Models\Form; use LaraZeus\Bolt\Models\FormsStatus; use LaraZeus\Bolt\Models\Response; class ResponsesPerStatus extends PieChartWidget { - public ?Model $record = null; + public Form $record; protected int|string|array $columnSpan = [ 'sm' => 1, @@ -24,10 +24,7 @@ protected function getHeading(): string protected function getData(): array { - if ($this->record === null) { - return []; - } - + $dataset = []; $statuses = FormsStatus::get(); foreach ($statuses as $status) { $dataset[] = Response::query() diff --git a/src/Http/Livewire/FillForms.php b/src/Http/Livewire/FillForms.php index a91506f9..e4329eee 100644 --- a/src/Http/Livewire/FillForms.php +++ b/src/Http/Livewire/FillForms.php @@ -9,6 +9,9 @@ use LaraZeus\Bolt\Models\Form; use Livewire\Component; +/** + * @property mixed $form + */ class FillForms extends Component implements Forms\Contracts\HasForms { use Forms\Concerns\InteractsWithForms; @@ -40,7 +43,6 @@ public function mount($slug, $itemSlug = null) $this->item = Office::whereSlug($itemSlug)->firstOrFail(); }*/ - /** @phpstan-ignore-next-line */ $this->zeusForm = config('zeus-bolt.models.Form')::with(['sections', 'sections.fields'])->whereSlug($slug)->whereIsActive(1)->firstOrFail(); abort_if(optional($this->zeusForm->options)['require-login'] && ! auth()->check(), 401); @@ -49,6 +51,8 @@ public function mount($slug, $itemSlug = null) $this->zeusData[$field->id] = ''; } + $this->form->fill(); + event(new FormMounted($this->zeusForm)); //$rules = $validationAttributes = []; } diff --git a/src/Models/Category.php b/src/Models/Category.php index 22f1b140..39efb1e9 100644 --- a/src/Models/Category.php +++ b/src/Models/Category.php @@ -9,6 +9,10 @@ use Illuminate\Support\Facades\Storage; use Spatie\Translatable\HasTranslations; +/** + * @property string $updated_at + * @property string $logo + */ class Category extends Model { use HasFactory; diff --git a/src/Models/Collection.php b/src/Models/Collection.php index 6e4ae984..20634c63 100644 --- a/src/Models/Collection.php +++ b/src/Models/Collection.php @@ -7,6 +7,10 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +/** + * @property string $updated_at + * @property array $values + */ class Collection extends Model { use SoftDeletes; diff --git a/src/Models/Field.php b/src/Models/Field.php index 031a5117..ac4125e1 100644 --- a/src/Models/Field.php +++ b/src/Models/Field.php @@ -8,6 +8,11 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Spatie\Translatable\HasTranslations; +/** + * @property string $updated_at + * @property array $rules + * @property int $id + */ class Field extends Model { use SoftDeletes; diff --git a/src/Models/FieldResponse.php b/src/Models/FieldResponse.php index f6ad41f7..9148457d 100644 --- a/src/Models/FieldResponse.php +++ b/src/Models/FieldResponse.php @@ -7,6 +7,11 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +/** + * @property string $updated_at + * @property int $field_id + * @property int $form_id + */ class FieldResponse extends Model { use SoftDeletes; diff --git a/src/Models/Form.php b/src/Models/Form.php index acda1a0b..65be7459 100644 --- a/src/Models/Form.php +++ b/src/Models/Form.php @@ -5,9 +5,19 @@ use Database\Factories\FormFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\SoftDeletes; use Spatie\Translatable\HasTranslations; +/** + * @property string $updated_at + * @property int $is_active + * @property string $desc + * @property string $name + * @property string $slug + */ class Form extends Model { use SoftDeletes; @@ -36,32 +46,37 @@ protected static function newFactory() return FormFactory::new(); } - public function user() + public function user(): BelongsTo { return $this->belongsTo(config('auth.providers.users.model')); } - public function category() + /** @phpstan-return BelongsTo