yemenpoint / filament-custom-fields
There is no license information available for the latest version (v1.0) of this package.
Filament Custom Fields
v1.0
2022-09-07 17:57 UTC
Requires
- filament/filament: 2.*
README
Installation
You can install the package via composer:
composer require yemenpoint/filament-custom-fields
Optionally, you can publish config and migration using
php artisan vendor:publish --tag="filament-custom-fields-migrations"
php artisan vendor:publish --tag="filament-custom-fields-config"
//then migrate
php artisan migrate
Config
filament-custom-fields.php
<?php use Yemenpoint\FilamentCustomFields\Resources\CustomFieldResource; use Yemenpoint\FilamentCustomFields\Resources\CustomFieldResponseResource; return [ 'resources' => [ CustomFieldResource::class, CustomFieldResponseResource::class, ], //model options will appear in CustomFieldResource 'models' => [ // \App\Models\Trying::class => "trying", ], "navigation_group" => "Custom Fields", "custom_fields_label" => "Custom Fields", "custom_field_responses_label" => "Custom Fields Responses", ];
Usage
CreateRecord Page
use Yemenpoint\FilamentCustomFields\CustomFields\FilamentCustomFieldsHelper; protected function afterCreate() { FilamentCustomFieldsHelper::handle_custom_fields_request($this->data, $this->getModel(), $this->record->id); } protected function getFormSchema(): array { return [ ...parent::getFormSchema(), ...FilamentCustomFieldsHelper::custom_fields_form($this->getModel(), data_get($this->record,"id")) ]; }
EditRecord Page
use Yemenpoint\FilamentCustomFields\CustomFields\FilamentCustomFieldsHelper; public function afterSave() { //this will handle_custom_fields_request FilamentCustomFieldsHelper::handle_custom_fields_request($this->data, $this->getModel(), $this->record->id); } protected function getFormSchema(): array { return [ ...parent::getFormSchema(), ...FilamentCustomFieldsHelper::custom_fields_form($this->getModel(), data_get($this->record,"id")) ]; }
Then add Column to see values
use Yemenpoint\FilamentCustomFields\CustomFields\FilamentCustomFieldsHelper; // show CustomFieldResponses in Resource column public static function table(Table $table): Table { return $table ->columns([ FilamentCustomFieldsHelper::custom_fields_column() ]); }
Images
Credits
License
The MIT License (MIT). Please see License File for more information.