Roland Barkóczi
How should I define the exportAction exporter class in order to export hasMany relation?
Use case:
- I have a Product model, product has many prices.
I would like to export these prices in csv/excel format. Ideally add these values in separate columns:
SKU | PRODUCT_NAME | ..... | Price 1 | Price 2 |
Could you help me on this topic?
5 replies
How to manage ManyToMany relation in TableBuilder and FormBuilder?
I have the following models
Product
- id
- name
Pricelist
- id
- name
ProductPrice
- id
- product_id
- pricelist_id
- price
I want to create a dynamic table on product listing page, where all the Pricelist are listed as columns (e.g. Retail, Reseller, Discount) and respectively the belonging product prices.
I defined these functions in Product model:
Furthermore I tried this code in the ProductRelationsManager table columns function:
So it creates all the pricelist columns, but I have no clue what should I add to the TextColumn::make() parameter in order to reach the given price belonging to the actual pricelist.
Also have no clues how to define the form, what should I add to the TextInput::make() as parameter.
47 replies
Reuse Filament Login and Registration Form outside the panel
Hello Guys,
Could you give me tips how can I replace the Breeze login and registration form with the filament ones? Can I point out the filament registration page in my routes/auth J
Or should I rework somehow the pages.auth.register blade template?
Thanks in advance for your help!
2 replies
Policy depends on request path
Hello All,
I have the following problem:
I have a [event] resource and the resource view page have a couple of relations (eg. attendees, vendors, etc).
I want to add policies to these relations, but to determine if the given user has access to an operation I need the event id {record}.
I tried to reach the request route parameter (request()->route()->parameter('record');), it works, but when I change tab, the livewire call (livewire/update) behind the scene refresh the data and the given operation will be refused due to the livewire call does not have the {record} parameter in the url .
As a workaround I thought to save the event_id to a session variable, but this will cause a problem when a user have multiple browser window with different event to view.
Question how can I reach an URL parameter and make it available for the subsequent livewire calls?
7 replies
Spatie Media Library responsiveImages How to convert to webp?
I tried to google for it but I did not found: how can I configure this plugin or the underlying Laravel-medialibrary to store the responsive images in webp format instead of jpg ?
2 replies
spatie translatable how to define form schema in a correct way
Hello all,
could you please give me guidance how suppose to define the form schema for the translatable fields?
My issue:
- if I add the localswitcher to the create and edit page, I define the schema as following:
But I receive the following validation error:
2 replies
Translation hasMany relation: how to populate form and field by locale
I have to a model: Category, it has a relation CategoryI10n which has a field: locale.
In the Category model I defined the relation:
I iterate through the available locales, create tabs, and text fields:
TextInput::make("name_$locale")
Then in the CreateCategory.php I implemented a custom handleRecordCreation function, which creates the necessary records in the relation.
But I have no clue, how to display only one translation record corresponds to the current record:
- if I add TextColumn::make("translations.name")
, it displays all the 3 available translations.
- I tried to write a __get()
function in Category model, if the property is name_en, name_fr it query the relation and give back the correct value. It works well in the tinker, but for some reason the TextColumn::make("name_en") does not call the __get()
method.
Can you help me here how would you handle this problem?
Thank you in advance!13 replies
Update RichEditor based on other field
I would like to pre-populate a RichEditor field if another field changes:
TextInput::make('Prompt')
->label(__('AI Assistant'))
->afterStateUpdated(function (Set $set,) {
$set('content', 'Foobar');
})
->live(onBlur: 500)
->columnSpan(2),
RichEditor::make('content')
->required()
->columnSpanFull(),
But it does not work. It works with a plain TextInput. What I'm doing wrong?6 replies
user model with PK type string
I encountered with a rather strange bug:
- I installed a fresh laravel 11 app, then I added the filement plugin, migrated the database, created a user, and I was able to log in to the panel without any issue.
Because of business requirements, I want to change the User model primary key to uuid ($table->uuid('id')->primary(); in my migration file), I also added
public $keyType = 'string';
public $incrementing = false;
...
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->id = (string) uniqid("usr_");
});
}
to my User model.
Refreshed the database, recreated a new user, but after these changes I cannot log in anymore into the app.
I debugged the app, the user record queried correctly at login, but it redirects back to the login screen, because in the vendor/filament/filament/src/Http/Middleware/Authenticate.php file, line 22:
if (!$guard->check()) {
$this->unauthenticated($request, $guards);
return;
}
the $guard->check() returns null.
Could you give me any clue, why it isn't working with PK type string?
15 replies