GizaRex
GizaRex
FFilament
Created by GizaRex on 5/25/2024 in #❓┊help
Optional Repeater
So I want to create an optional repeater on an hasMany Relationship. Everything is working when the repeater is filled, but when I dont need to fill it I get the error Integrity constraint violation: 19 NOT NULL constraint failed , then I searched in the discord for solutions. One that I found was make the column nullable. But I think that does not make any sense that you store data into the db that you just cant use. Is there another solution that I can use?
2 replies
FFilament
Created by GizaRex on 5/8/2024 in #❓┊help
Country Flags
Is there an way to show countries flags in a table based on an given country name or country code? I already tried it with an package that gives me svg as an blade component, but that did not generate the svg. Thanks in advance
3 replies
FFilament
Created by GizaRex on 4/25/2024 in #❓┊help
How can I set an Icon if file exists
How can I achieve if an image/file exists I can set an Icon in an table column and if the file/image not exist I would set an default icon. Cant seem to get the record in an IconColumn. Im usign spatie media library for filament file uploads
5 replies
FFilament
Created by GizaRex on 4/22/2024 in #❓┊help
Test editOptionForm
Hey everyone. I want to test my form that it is filled with the given data. But when I run the test I always get this error Filament\Forms\Components\Select::getEditOptionActionFormData(): Return value must be of type array, null returned How can I fix this? Dont see anything in de docs about editOptionForm testing. When I remove the editOptionForm from the form, the test is passed. This is my test in pest
it('can fill in the edit page with retrieved data', function () {
// Arrange
$recipe = Recipe::factory()
->has(RecipeIngredient::factory(2), 'ingredients')
->has(RecipeStep::factory(2), 'steps')
->create();

// Act & Assert
livewire(RecipeResource\Pages\EditRecipe::class, [
'record' => $recipe->getRouteKey(),
])
->assertFormSet([
'title' => [
'nl' => $recipe->title,
'en' => $recipe->title,
'fr' => $recipe->title,
],
'recipe_ingredients' => [
'record-1' => [
'quantity' => $recipe->ingredients[0]->quantity,
'ingredient_id' => $recipe->ingredients[0]->ingredient_id,
],
'record-2' => [
'quantity' => $recipe->ingredients[1]->quantity,
'ingredient_id' => $recipe->ingredients[1]->ingredient_id,
],
],
'recipes_steps' => [
'record-1' => [
'step_number' => $recipe->steps[0]->step_number,
'description' => [
'en' => $recipe->steps[0]->description,
'nl' => $recipe->steps[0]->description,
'fr' => $recipe->steps[0]->description,
],
],
],
]);
});
it('can fill in the edit page with retrieved data', function () {
// Arrange
$recipe = Recipe::factory()
->has(RecipeIngredient::factory(2), 'ingredients')
->has(RecipeStep::factory(2), 'steps')
->create();

// Act & Assert
livewire(RecipeResource\Pages\EditRecipe::class, [
'record' => $recipe->getRouteKey(),
])
->assertFormSet([
'title' => [
'nl' => $recipe->title,
'en' => $recipe->title,
'fr' => $recipe->title,
],
'recipe_ingredients' => [
'record-1' => [
'quantity' => $recipe->ingredients[0]->quantity,
'ingredient_id' => $recipe->ingredients[0]->ingredient_id,
],
'record-2' => [
'quantity' => $recipe->ingredients[1]->quantity,
'ingredient_id' => $recipe->ingredients[1]->ingredient_id,
],
],
'recipes_steps' => [
'record-1' => [
'step_number' => $recipe->steps[0]->step_number,
'description' => [
'en' => $recipe->steps[0]->description,
'nl' => $recipe->steps[0]->description,
'fr' => $recipe->steps[0]->description,
],
],
],
]);
});
2 replies
FFilament
Created by GizaRex on 4/17/2024 in #❓┊help
What is the best approach?
What is the best approach to upload images but also being able to manage and translate the name and alt text? Has anyone ever done this before? Or can anyone push me in the right direction? I'm already using this package in my project mvenghaus/filament-plugin-translatable-inline. So I was thinking of using this package spatie-laravel-media-library-plugin but I don't get it in my translation text input. Does anyone have any alternatives on how I can achieve it? Thank already if someone can help me
3 replies
FFilament
Created by GizaRex on 4/15/2024 in #❓┊help
Testing edit form with repeater
Hello I want to test if my form is filled with the retrieved data. But I always get Failed asserting that null matches expected '200g'. This is my test:
it('can fill in the edit page with retrieved data', function (){
// Arrange
$recipe = Recipe::factory()
->has(RecipeIngredient::factory(2), 'ingredients')
->create();

// Act & Assert
livewire(RecipeResource\Pages\EditRecipe::class, [
'record' => $recipe->getRouteKey(),
])
->assertFormSet([
'title' => [
'nl' => $recipe->title,
'en' => $recipe->title,
'fr' => $recipe->title,
],
'recipe_ingredients' => $recipe->ingredients()->get()->map(function ($ingredient) {
return [
'quantity' => $ingredient->quantity,
'ingredient_id' => $ingredient->ingredient_id,
];
})->toArray()
]);
});
it('can fill in the edit page with retrieved data', function (){
// Arrange
$recipe = Recipe::factory()
->has(RecipeIngredient::factory(2), 'ingredients')
->create();

// Act & Assert
livewire(RecipeResource\Pages\EditRecipe::class, [
'record' => $recipe->getRouteKey(),
])
->assertFormSet([
'title' => [
'nl' => $recipe->title,
'en' => $recipe->title,
'fr' => $recipe->title,
],
'recipe_ingredients' => $recipe->ingredients()->get()->map(function ($ingredient) {
return [
'quantity' => $ingredient->quantity,
'ingredient_id' => $ingredient->ingredient_id,
];
})->toArray()
]);
});
This is my form:
Section::make('Ingrediënten')
->schema([
Repeater::make('recipe_ingredients')
->label('')
->relationship('ingredients')
->schema([
TextInput::make('quantity')
->label('Hoeveelheid')
->required(),
Select::make('ingredient_id')
->relationship('ingredient', 'name')
->preload()
->searchable()
->label('Naam')
->required(),
])->columns(2),
]),
Section::make('Ingrediënten')
->schema([
Repeater::make('recipe_ingredients')
->label('')
->relationship('ingredients')
->schema([
TextInput::make('quantity')
->label('Hoeveelheid')
->required(),
Select::make('ingredient_id')
->relationship('ingredient', 'name')
->preload()
->searchable()
->label('Naam')
->required(),
])->columns(2),
]),
How can I fix my test? Or is it something that I do completely wrong?
2 replies
FFilament
Created by GizaRex on 4/11/2024 in #❓┊help
TranslatableContainer in Repeater
I have an issue I cant seem to resolve. So I want to create an repeater for recipes steps and each step should be translated. Here for I use "mvenghaus/filament-plugin-translatable-inline": "3.0". But I get this error Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization With this code below. When I remove the TranslatableContainer then it works. Hope somebody can help me
Section::make('Receptstappen')
->schema([
Repeater::make('recipes_steps')
->label('')
->relationship('steps')
->schema([
TranslatableContainer::make(
TextInput::make('description')
->label('Beschrijving')
->required(),
),
]),
])
Section::make('Receptstappen')
->schema([
Repeater::make('recipes_steps')
->label('')
->relationship('steps')
->schema([
TranslatableContainer::make(
TextInput::make('description')
->label('Beschrijving')
->required(),
),
]),
])
5 replies