morawcik
morawcik
FFilament
Created by morawcik on 7/2/2024 in #❓┊help
Validation messages not working on custom page?
Hi, I have custom page
class Company extends Page implements HasForms {
use InteractsWithForms;

// ....
}
class Company extends Page implements HasForms {
use InteractsWithForms;

// ....
}
Each field has custom error messages like
->validationMessages([
'accepted' => 'Custom error message',
])
->validationMessages([
'accepted' => 'Custom error message',
])
but submitting form shows the default Laravel messages.
9 replies
FFilament
Created by morawcik on 6/15/2024 in #❓┊help
Column avg() not working? I'm sure i'm missing something
I don't know if I'm missing something but... I have model Review with relations:
public function product()
{
return $this->belongsTo(Product::class);
}

public function productReviews()
{
return $this->hasManyThrough(Review::class, Product::class, 'id', null, 'product_id');
}
public function product()
{
return $this->belongsTo(Product::class);
}

public function productReviews()
{
return $this->hasManyThrough(Review::class, Product::class, 'id', null, 'product_id');
}
then Product model:
public function reviews()
{
return $this->hasMany(Review::class);
}
public function reviews()
{
return $this->hasMany(Review::class);
}
In Review resource I have this:
return $table
->modifyQueryUsing(function($query) {
$query->with('productReviews');
//$query->withAvg('productReviews', 'rating');
})
->columns([
Tables\Columns\TextColumn::make('product')->state(function (Review $record): string {
return $record->product->translateAttribute('name');
})->label('Produkt'),

Tables\Columns\TextColumn::make('avg')
->avg('productReviews', 'rating')
->label('Avg'),
]);
return $table
->modifyQueryUsing(function($query) {
$query->with('productReviews');
//$query->withAvg('productReviews', 'rating');
})
->columns([
Tables\Columns\TextColumn::make('product')->state(function (Review $record): string {
return $record->product->translateAttribute('name');
})->label('Produkt'),

Tables\Columns\TextColumn::make('avg')
->avg('productReviews', 'rating')
->label('Avg'),
]);
In avg column I have nothing but when I'm using query builder withAvg i'm getting in review ($record) object. What I'm missing with this column avg() ?
4 replies
FFilament
Created by morawcik on 6/15/2024 in #❓┊help
Multiple icons in column
Hi, It is possible to use/add multiple icons in one column? I mean for e.g. in reviews resources in column rating instead of just number 1-5 to use star icons (for e.g. 3 "full" stars and 2 empty)
3 replies
FFilament
Created by morawcik on 6/9/2024 in #❓┊help
2 levels of tenancy (nested tenancy)
Hi, It is possible to have 2 levels of tenancy? I mean one level it would be for user companies (each user can have multiple companies) and then each company could have multiple stores with different workers, products, etc etc. If it's not possible then any hint how It could be done? Thanks.
4 replies
FFilament
Created by morawcik on 5/30/2024 in #❓┊help
Pivot data in model/resource table
Hi. I have Product model with relation:
public function customerGroups(): BelongsToMany
{
return $this->belongsToMany(CustomerGroup::class, "customer_group_product")
->withPivot(['purchasable', 'visible', 'enabled', 'starts_at', 'ends_at'])->withTimestamps();
}
public function customerGroups(): BelongsToMany
{
return $this->belongsToMany(CustomerGroup::class, "customer_group_product")
->withPivot(['purchasable', 'visible', 'enabled', 'starts_at', 'ends_at'])->withTimestamps();
}
I tried to show purchasable in resource table but without success. I added column:
Tables\Columns\TextColumn::make('customerGroups.pivot.purchasable')
->badge()
->label('purchasable')
Tables\Columns\TextColumn::make('customerGroups.pivot.purchasable')
->badge()
->label('purchasable')
but it is always empty. When i change it to customerGroups.name the I get those names. I even tried to dump $state inside of color() method. I started with just customerGroups and I got this:
{"id":1,"name":"Detal","handle":"detal","default":1,"attribute_data":null,"created_at":"2023-07-31T21:53:13.000000Z","updated_at":"2023-08-02T20:48:21.000000Z","pivot":{"product_id":142,"customer_group_id":1,"purchasable":1,"visible":1,"enabled":1,"starts_at":null,"ends_at":null,"created_at":"2023-08-13T08:33:37.000000Z","updated_at":"2024-05-30T18:26:16.000000Z"}}
{"id":1,"name":"Detal","handle":"detal","default":1,"attribute_data":null,"created_at":"2023-07-31T21:53:13.000000Z","updated_at":"2023-08-02T20:48:21.000000Z","pivot":{"product_id":142,"customer_group_id":1,"purchasable":1,"visible":1,"enabled":1,"starts_at":null,"ends_at":null,"created_at":"2023-08-13T08:33:37.000000Z","updated_at":"2024-05-30T18:26:16.000000Z"}}
and then if i tried customerGroups.pivot or customerGroups.pivot.purchasable I got nothing - like dd() even not fired
4 replies
FFilament
Created by morawcik on 5/25/2024 in #❓┊help
JS files are commented
No description
11 replies
FFilament
Created by morawcik on 1/31/2024 in #❓┊help
Rich editor and new lines
Hi, Rich editor shouldn't save a new lines? I'm trying to write something with new lines but after save and reload page it is without new lines.
1 replies