Stefan
Stefan
Explore posts from servers
TLCTuto's Laravel Corner
Created by Stefan on 3/4/2024 in #💡filament
form builder
can anyone help me hoe to think this? thanks!
3 replies
FFilament
Created by Stefan on 3/4/2024 in #❓┊help
form builder
can anyone help me how to think this form builder? thanks!
4 replies
FFilament
Created by Stefan on 1/13/2024 in #❓┊help
error: Group::isContained does not exist
On the Resource classes where I use Form Group Components, on create and edit routes i get Method Filament\Forms\Components\Group::isContained does not exist. If I comment the Forms\Components\Group::make()->schema([...]) and I use Forms\Components\Tabs\Tab::make()->schema([...]) I get Tab::isContained does not exist. Thanks!
2 replies
TLCTuto's Laravel Corner
Created by Stefan on 1/11/2024 in #💡filament
attach properties to products - many to many relation
I have ProductResource and I want to associate some Properties to each product. For this I made a PropertiesRelationalManager The PropertyResource is bind of Property model and to the properties table. The properties table have the 2 columns, id and name The property values are stored in the property_values table which have the following columns: id, property_id and value I have a pivot table product_property with the following columns: id, product_id, property_value_id, property_id and quantity I created a PropertiesRelationManager and registered on the ProductResource and it’s form method looks like this: public function form(Form $form): Form { return $form ->schema([ Forms\Components\Select::make('property_id')->label('Properties') ->relationship('properties', 'name') ->options(Property::all()->pluck('name', 'id')) ->live() ->required(), Forms\Components\Select::make('property_value_id')->label('Values') ->relationship('properties.values', 'value') ->options(function (Forms\Get $get) { $property = Property::find($get('property_id')); return $property ? $property->values->pluck('value', 'id') : []; }) ->live() ->required(), Forms\Components\TextInput::make('quantity'), ]); } Now when I want to save, I get Call to a member function associate() on null Any help will be much appreciated!
3 replies
FFilament
Created by Stefan on 1/9/2024 in #❓┊help
attach properties to products
I want to assign properties to the products: Product Model:
public function properties()
{
return $this->hasMany(ProductProperty::class);
}
public function properties()
{
return $this->hasMany(ProductProperty::class);
}
Product Table products fields:
id,name,etc.
id,name,etc.
I have registered PropertiesRelationManager::class on the ProductRequest Property Model:
public function values()
{
return $this->hasMany(PropertyValue::class);
}
public function values()
{
return $this->hasMany(PropertyValue::class);
}
Property Table properties fields:
id,name,etc.
id,name,etc.
PropertyValue Model:
public function product()
{
return $this->belongsTo(Product::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
Table property_values with the followings fields:
id,property_id,value,etc.
id,property_id,value,etc.
ProductProperty Model:
public function product()
{
return $this->belongsTo(Product::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
ProductProperty Table product_properties fields:
id,product_id,property_id,property_value_id,etc.
id,product_id,property_id,property_value_id,etc.
PropertiesRelationManager:
public function form(Form $form)
{
return $form
->schema([
Select::make('property_id')
->options(Property::all()->pluck('name', 'id'))
->live(),
Select::make('property_value_id')
->options(fn (Forms\Get $get): Collection => PropertyValue::query()
->where('property_id', $get('property_id'))
->pluck('value', 'id'))
->multiple()
->live(),
]);
}
public function form(Form $form)
{
return $form
->schema([
Select::make('property_id')
->options(Property::all()->pluck('name', 'id'))
->live(),
Select::make('property_value_id')
->options(fn (Forms\Get $get): Collection => PropertyValue::query()
->where('property_id', $get('property_id'))
->pluck('value', 'id'))
->multiple()
->live(),
]);
}
When I save, I get: Array to string conversion I guess that this happens because I declared multiple() on Select::make('property_value_id') and what I select is passed as array and my field property_value_id accepts an integer. For each selected value in this Select::make('property_value_id') I want to add a record in the product_properties table not a single record with all the values as if the property_value_id would be of type json. Thanks for your time!
2 replies
FFilament
Created by Stefan on 1/2/2024 in #❓┊help
Add a filament Table into a form Section
No description
4 replies
FFilament
Created by Stefan on 12/30/2023 in #❓┊help
update relative table
I have a product resource class where in the main form I have only fields that belongs to the products table and all updates go fine. Now, if I add two more fields to the main form, like gross_price, net_price. I want to store them in a table named product_prices. When I try to update the price fields that are the product_prices table, I get an error
update
`products`
SET
`price_gross` = 2,
update
`products`
SET
`price_gross` = 2,
It tries to update the products table and not the product_prices table.

What to do in order to be able to also update the relative tables when I update any of the fields in the form? Thanks in advance!
7 replies
FFilament
Created by Stefan on 10/28/2023 in #❓┊help
Route [login] not defined.
No description
4 replies