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
<?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",
];
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"))
];
}
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"))
];
}
use Yemenpoint\FilamentCustomFields\CustomFields\FilamentCustomFieldsHelper;
// show CustomFieldResponses in Resource column
public static function table(Table $table): Table
{
return $table
->columns([
FilamentCustomFieldsHelper::custom_fields_column()
]);
}
The MIT License (MIT). Please see License File for more information.