Comments (2)
that was the same for me if you have a solution for this ,pldas
My Resource
<?php
namespace App\Filament\Resources;
use App\Filament\Enums\AdvantageLayoutTypeEnum;
use App\Filament\Resources\ProductCategoryResource\Pages;
use App\Models\ProductCategory;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Concerns\Translatable;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Support\Str;
class ProductCategoryResource extends Resource
{
use Translatable;
protected static ?string $model = ProductCategory::class;
protected static ?string $navigationIcon = 'heroicon-o-queue-list';
protected static ?string $navigationGroup = 'Manage Products';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Forms\Set $set): void {
if ($operation !== 'create') {
return;
}
$set('slug', Str::slug($state));
}),
Forms\Components\TextInput::make('slug')
->disabled()
->dehydrated()
->required()
->maxLength(255)
->unique(ProductCategory::class, 'slug', ignoreRecord: true),
Forms\Components\FileUpload::make('icon')
->image(),
Forms\Components\FileUpload::make('image')
->image(),
Forms\Components\Repeater::make('advantages')
->schema([
Forms\Components\TextInput::make('title')
->required(),
Forms\Components\Repeater::make('contents')
->schema([
Forms\Components\TextInput::make('order')
->numeric()
->required(),
Forms\Components\TextInput::make('title')
->required(),
Forms\Components\FileUpload::make('img')
->disk('public')
->directory('advantages')
->image(),
Forms\Components\MarkdownEditor::make('desc')
->required(),
Forms\Components\Select::make('type')
->options(AdvantageLayoutTypeEnum::class)
->required(),
])
->minItems(1)
->collapsible()
->required(),
])
->minItems(1)
->addable(false)
->deletable(false)
->required()
->columnSpanFull(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable(),
Tables\Columns\TextColumn::make('slug')
->searchable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\ImageColumn::make('icon'),
Tables\Columns\ImageColumn::make('image'),
// Tables\Columns\TextColumn::make('advantages.title')
// ->searchable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListProductCategories::route('/'),
'create' => Pages\CreateProductCategory::route('/create'),
'edit' => Pages\EditProductCategory::route('/{record}/edit'),
];
}
}
my migration
Schema::create('product_categories', function (Blueprint $table): void {
$table->id();
$table->text('name');
$table->string('slug')->unique();
$table->string('icon')->nullable()->default(null);
$table->string('image')->nullable()->default(null);
$table->json('advantages')->nullable();
$table->timestamps();
});
my seeder
$category = ProductCategory::create([
'name' => $categoriesName,
'slug' => Str::slug($categoriesName),
'icon' => 'advantages/01HZE5794C7ADXYKC9HPXHFHS2.png',
'image' => 'advantages/01HZE5794A1KQQYGAQQ9V7Y8B6.png',
'advantages' => [
[
'title' => 'Advantages of Bio Stimulant',
'contents' => [
[
'order' => 1,
'title' => 'BioStimulants Assits In Combating The Effects Of Enveromental Stresses',
'img' => 'advantages/01HZE5794A1KQQYGAQQ9V7Y8B6.png',
'desc' => fake()->paragraph(),
'type' => 'right section',
], [
'order' => 2,
'title' => 'Qui aute corporis no',
'img' => 'advantages/01HZE5794C7ADXYKC9HPXHFHS2.png',
'desc' => fake()->paragraph(),
'type' => 'left section',
],
[
'order' => 3,
'title' => 'Advantage 1',
'img' => 'advantage1.png',
'desc' => fake()->paragraph(),
'type' => 'right section',
],
[
'order' => 4,
'title' => 'Advantage 2',
'img' => 'advantage2.png',
'desc' => fake()->paragraph(),
'type' => 'final section',
],
],
],
],
]);
from filament.
Not sure if Iām having the same issue, but here:
app/Models/Guide.php
public function items(): BelongsToMany
{
return $this->belongsToMany(Item::class);
}
Forms\Components\Repeater::make('steps')
->schema([
Forms\Components\Select::make('item')
->relationship(name: 'items', titleAttribute: 'title')
->disableOptionsWhenSelectedInSiblingRepeaterItems()
->required(),
Forms\Components\Textarea::make('description')
->autosize(),
]),
Desired behaviour:
To sync all repeater step items into the guide_item
table.
Current behaviour:
It removes all current relations and attaches only the last repeater step item.
from filament.
Related Issues (20)
- IntlException Constructor failed HOT 1
- `mutateRecordDataUsing` not mutating data when used with `ReplicateAction` HOT 1
- composer require beier/filament-pages:^2.1 HOT 2
- ExportAction in RelationManager
- Route [filament.lunar.resources.products.review] not defined. HOT 1
- Textarea in modal produces several JS errors
- Performance issue with table HOT 2
- FileUpload uncontrollably modifying the file path
- Bug with repeater state when using model eager loading by default
- Simple Repeater with FileUpload HOT 1
- Table Action Group Cannot Click 4th Action HOT 2
- FileUpload overlapping other elements HOT 2
- Remove table empty state Blade component
- `ExportAction` / `ImportAction` doesn't respect $modelLabel defined in Resource class
- Using `->path('/')` with Apache alias causes `Method Not Allowed` error with routes cached
- Modal Behavior Issue with Multiple Relations HOT 1
- Problem with modals and QueryBuilder
- Checkbox state sharing issue in dynamically generated CheckboxList HOT 3
- Many-to-many pivot columns not countenanced when column name clashes with another parent column
- FileUpload Component Overlapping Next Element When Accepting Multiple Files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filament.