Keika
Keika
FFilament
Created by Keika on 7/31/2024 in #❓┊help
How to add a column in an ImportCsv Action that is not in the csv file
Hi, my action wants to compare an amount in csv to an amount on the record. If the amount is the same, the status on the record needs to change to "paid". Rather simple, however it seems that the coulmns that are passed to the importer are only the columns defined in the getColumns method. I tried adding a column inside of resolveRecord by doing $this->data['status'] = 'paid; but the job does not see it (I used Ray to check). How can I add this column so that the record will be updated correcly WITHOUT changing the CSV file? Thanks
2 replies
FFilament
Created by Keika on 7/30/2024 in #❓┊help
Import Action Examples
Hi, are there examples/tutorials on how to create a new Import Action? For my import I need to update records, but the field I need to change is a status which would not be part of the CSV file that I have. I have to compare an amount column with what's in the CSV and change the status to paid if the amounts match. I don't really get how to create my own job for the processing, any help would be great. Thanks
4 replies
FFilament
Created by Keika on 7/30/2024 in #❓┊help
How to have a color per label in a doughnut Chart?
Hi, I have a widget doughnut that displays Payments according to their status. So far so good. Now I want each status to have a color on the chart, preferably matching the color of the status I setup in the PaymentStatus enum. How can I do that? So far I have this:
enum PaymentStatus: string implements HasColor
{
case Paid = 'paid';
case Due = 'due';
case Overdue = 'overdue';
case Reminded = 'reminded';

public function getColor(): string|array|null
{
return match ($this) {
self::Paid => 'success',
self::Due => 'warning',
self::Overdue => 'success',
self::Reminded => Color::Orange,
};
}
}
enum PaymentStatus: string implements HasColor
{
case Paid = 'paid';
case Due = 'due';
case Overdue = 'overdue';
case Reminded = 'reminded';

public function getColor(): string|array|null
{
return match ($this) {
self::Paid => 'success',
self::Due => 'warning',
self::Overdue => 'success',
self::Reminded => Color::Orange,
};
}
}
Chart:
'datasets' => [
[
'label' => 'Payments',
'data' => $grouped->map(fn ($group) => $group->sum('amount'))->flatten()->toArray(),
"backgroundColor" => [
"rgba(" . PaymentStatus::Reminded->getColor()[500] . ")", // Not very nice way of getting a color
"rgba(" . PaymentStatus::Paid->getColor() . ")", // As this one is set to 'success' I don't have access to the actual color. It returns 'success'
],
'datasets' => [
[
'label' => 'Payments',
'data' => $grouped->map(fn ($group) => $group->sum('amount'))->flatten()->toArray(),
"backgroundColor" => [
"rgba(" . PaymentStatus::Reminded->getColor()[500] . ")", // Not very nice way of getting a color
"rgba(" . PaymentStatus::Paid->getColor() . ")", // As this one is set to 'success' I don't have access to the actual color. It returns 'success'
],
thanks for any help possible
2 replies
FFilament
Created by Keika on 7/29/2024 in #❓┊help
How to create navigation with groups liked to subqueries
Hi there, say I have a User table/resource, with a created_at field. Is it possible, and if so, how can I have a nnavigation bar that would look like this: User | Q1 2024 | Q2 2024 | Q3 2024 I want to be able to have 4 links for the current year and its quarters, and when clicked dispay the resource table with the proper filters actvated ( I have a filter for filtering per quarter, so basically I have access to a link to that page with the filters active, but I don't know how to setup this navigation dynamically so that each year, to moves to the current year) Thanks
5 replies
FFilament
Created by Keika on 7/24/2024 in #❓┊help
How to get current viewing resource ID in a Widget
Hello all, I'm trying to build a simple widget showing a customer's bookings over time. So far I have the widget chart showing all booking for all users, using the Trend library as stated in the docs. No problem. Thing is the widget is in a View page of a single customer, How can I get the ID of the current viewed customer, to pass it to the Trend request?
$data = Trend::query(Booking::where('customer_id', 1)) // << Want to replace the 1 here
->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();
$data = Trend::query(Booking::where('customer_id', 1)) // << Want to replace the 1 here
->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();
5 replies
FFilament
Created by Keika on 1/3/2024 in #❓┊help
Description text is same size as TextColumn
No description
8 replies