ddoddsr
ddoddsr
FFilament
Created by ddoddsr on 10/22/2024 in #❓┊help
Add a Create and edit button
In a RelationManager: How can I use custom or CreateAction to Create the record and keep editing and not Close the modal
14 replies
FFilament
Created by ddoddsr on 10/3/2024 in #❓┊help
export successful no notification
I am running a bulk action export and the process ends with a promise of a download notification and download link. The data shows up in storage/app/public/filament_exports/ But the notification never comes. The data in the notification table row data:
"body": "Your client export has completed and 1 row exported.",
"color": null,
"duration": "persistent",
"icon": "heroicon-o-check-circle",
"iconColor": "success",
"status": "success",
"title": "Export completed",
"view": "filament-notifications::notification",
"viewData": [],
"format": "filament"
"body": "Your client export has completed and 1 row exported.",
"color": null,
"duration": "persistent",
"icon": "heroicon-o-check-circle",
"iconColor": "success",
"status": "success",
"title": "Export completed",
"view": "filament-notifications::notification",
"viewData": [],
"format": "filament"
I get other notifications why not these?
3 replies
FFilament
Created by ddoddsr on 9/19/2024 in #❓┊help
modifyQueryUsing ->join changes $record->id
Building a Dashboard widget to display Team Notes. Works except using join or leftJoin changes $record->id from the original query table to the "joined" table. I want to use the original table id for a link to the record and it changes to the id of the "joined' table .
return $table
->query(Persona::query())
->modifyQueryUsing(fn(Builder $query) =>
$query
->where('am_notes','!=','')
// Jacks up the links
->join('users', 'users.id', '=', 'personas.client_id')
->where(function(Builder $query) use ($client_id){
if ($client_id) {
$query->where('client_id', $client_id);
}
})
->where(function(Builder $query) use ($csm_id, $am_id){
if ($csm_id) {
$query->where('users.customer_support_manager_id', $csm_id);
}
if ($am_id) {
$query->where('users.account_manager_id', $am_id);
}
})
)

->columns([
Tables\Columns\TextColumn::make('client.name')->sortable()
//changes with join
->url(fn ($record): string => "/clients/$record->client_id/edit"),
Tables\Columns\TextColumn::make('li_email')
//changes with join
->url(fn (Persona $record): string => "/personas/$record->id/edit")
->openUrlInNewTab(),
Tables\Columns\TextColumn::make('am_notes')
->label('Instructions'),
]);
return $table
->query(Persona::query())
->modifyQueryUsing(fn(Builder $query) =>
$query
->where('am_notes','!=','')
// Jacks up the links
->join('users', 'users.id', '=', 'personas.client_id')
->where(function(Builder $query) use ($client_id){
if ($client_id) {
$query->where('client_id', $client_id);
}
})
->where(function(Builder $query) use ($csm_id, $am_id){
if ($csm_id) {
$query->where('users.customer_support_manager_id', $csm_id);
}
if ($am_id) {
$query->where('users.account_manager_id', $am_id);
}
})
)

->columns([
Tables\Columns\TextColumn::make('client.name')->sortable()
//changes with join
->url(fn ($record): string => "/clients/$record->client_id/edit"),
Tables\Columns\TextColumn::make('li_email')
//changes with join
->url(fn (Persona $record): string => "/personas/$record->id/edit")
->openUrlInNewTab(),
Tables\Columns\TextColumn::make('am_notes')
->label('Instructions'),
]);
6 replies
FFilament
Created by ddoddsr on 9/4/2024 in #❓┊help
npm run build error, run dev not working
Followed the directions I made a new theme
php artisan make:filament-theme admin
php artisan make:filament-theme admin
Followed these steps
⇂ First, add a new item to the `input` array of `vite.config.js`: `resources/css/filament/admin/theme.css`
⇂ Next, register the theme in the admin panel provider using `->viteTheme('resources/css/filament/admin/theme.css')`
⇂ Finally, run `npm run build` to compile the theme
⇂ First, add a new item to the `input` array of `vite.config.js`: `resources/css/filament/admin/theme.css`
⇂ Next, register the theme in the admin panel provider using `->viteTheme('resources/css/filament/admin/theme.css')`
⇂ Finally, run `npm run build` to compile the theme
Run build does include my custom page and the tailwind class take effect! great. But I get a warning that does not make sense:
warn - The `content` option in your Tailwind CSS configuration is missing or empty.
warn - Configure your content sources or your generated CSS will be missing styles.
warn - https://tailwindcss.com/docs/content-configuration
warn - The `content` option in your Tailwind CSS configuration is missing or empty.
warn - Configure your content sources or your generated CSS will be missing styles.
warn - https://tailwindcss.com/docs/content-configuration
Also npm run dev does NOT effect my custom page changes Gist of files https://gist.github.com/ddoddsr/f777762adb35c1908546ce98a1d1e3b5
25 replies
FFilament
Created by ddoddsr on 8/25/2024 in #❓┊help
summarize calculated fields in footer
How can I add a custom calculation to the footer of a grouped table? These three columns show up great for each row and the footer group summarize works for the first two. Just cannot figure out the summarize for the third calculated column... Trying a custom summarizer:
TextColumn::make('leads_sum_connect_req')
->sum('leads', 'connect_req')
->summarize(Sum::make()->label('ConnctReq'))
->label('ConnctReq')
->description('ConnctReq'),

TextColumn::make('leads_sum_connected')
->sum('leads', 'connected')
->summarize(Sum::make()->label('Connected'))
->label('Connected')
->description('Connected'),

TextColumn::make('connected_percent')
->state(function($record){
return ( $record->leads_generated->sum('connected')) / ($record->leads_generated->sum('connection_request')+ .01) * 100;
})
->sortable()
->numeric(decimalPlaces: 1)
->summarize(
Summarizer::make()
->label('Connected %')
->using(function($record){ // , but [$record] was unresolvable.
return 99.9 ; // to test
return ( $record->leads_generated->sum('connected'))
/ ($record->leads_generated->sum('connection_request')+ .01) * 100;
})
)
TextColumn::make('leads_sum_connect_req')
->sum('leads', 'connect_req')
->summarize(Sum::make()->label('ConnctReq'))
->label('ConnctReq')
->description('ConnctReq'),

TextColumn::make('leads_sum_connected')
->sum('leads', 'connected')
->summarize(Sum::make()->label('Connected'))
->label('Connected')
->description('Connected'),

TextColumn::make('connected_percent')
->state(function($record){
return ( $record->leads_generated->sum('connected')) / ($record->leads_generated->sum('connection_request')+ .01) * 100;
})
->sortable()
->numeric(decimalPlaces: 1)
->summarize(
Summarizer::make()
->label('Connected %')
->using(function($record){ // , but [$record] was unresolvable.
return 99.9 ; // to test
return ( $record->leads_generated->sum('connected'))
/ ($record->leads_generated->sum('connection_request')+ .01) * 100;
})
)
With this I get an error:
An attempt was made to evaluate a closure for [Filament\Tables\Columns\Summarizers\Summarizer], but [$record] was unresolvable.
An attempt was made to evaluate a closure for [Filament\Tables\Columns\Summarizers\Summarizer], but [$record] was unresolvable.
14 replies
FFilament
Created by ddoddsr on 8/5/2024 in #❓┊help
summarizer group label
Is there a way to add a tooltip to the group name? I use an enum for the status field and would like to show the enum description in a tool tip or something.
2 replies
FFilament
Created by ddoddsr on 8/4/2024 in #❓┊help
importer resolveRecord() not running?
According to the docs , the function
resolveRecord()
resolveRecord()
runs for each line in the CSV file. It is not running for me.
public function resolveRecord(): ?AppType
{
logger('resolveRecord()');
return new AppType();
}
public function resolveRecord(): ?AppType
{
logger('resolveRecord()');
return new AppType();
}
I am getting a record for each line in the CSV. but itis not logging.
5 replies
FFilament
Created by ddoddsr on 8/3/2024 in #❓┊help
widget query filter on related field
No description
7 replies
FFilament
Created by ddoddsr on 7/22/2024 in #❓┊help
Get filter by date, using the table date as the options
Table has a report_week, which is the same for several records, the day the report ran. I can get a list of distinct values for the options but I cannot see how to adjust the query with that data.
SelectFilter::make('report_week')
->options(LeadGeneration::where('report_week', '!=', null)
->distinct('report_week')->pluck('report_week')),
SelectFilter::make('report_week')
->options(LeadGeneration::where('report_week', '!=', null)
->distinct('report_week')->pluck('report_week')),
This gives me a set of report weeks to select. How do I use this in the $query?
16 replies
FFilament
Created by ddoddsr on 7/21/2024 in #❓┊help
groups([ Group::make not showing first item
No description
4 replies
FFilament
Created by ddoddsr on 7/16/2024 in #❓┊help
I want to Display all time in same timezone
We are storing all date time values in UTC but need to display all values in a single timezone. The company runs on EST/EDT for simplicity of operations (for main office). The config app.timezone is UTC but I want entry and display in EST/EDT. Every user regardless of local timezone. DO I just add
->timezone('America/New_York')
->timezone('America/New_York')
to every field with
->date()
->date()
and
DatePicker::make('created_from')
DatePicker::make('created_from')
OR is there a global way to do this?
6 replies
FFilament
Created by ddoddsr on 7/2/2024 in #❓┊help
Why is my $record->save(); not working
Should I expect one of these to save the current record?
Action::make('Run Campaign')
->action(function (Campaign $record, Set $set) {
$set('status_id', CampaignStatusEnum::Run );
$record->save();
}),
Action::make('Run Campaign')
->action(function (Campaign $record, Set $set) {
$set('status_id', CampaignStatusEnum::Run );
$record->save();
}),
Or
Action::make('Pause Campaign')
->action(function (?Model $record, Set $set) {
$set('status_id', CampaignStatusEnum::Paused );
$record->save();
})
Action::make('Pause Campaign')
->action(function (?Model $record, Set $set) {
$set('status_id', CampaignStatusEnum::Paused );
$record->save();
})
The field changes on the scren but is not save.
10 replies
FFilament
Created by ddoddsr on 6/28/2024 in #❓┊help
Can I display a relation in Forms like I can in Table?
In my CampaignResource I have a title In the form a working Select
Forms\Components\Select::make('title_id')
->relationship('title', 'name')
Forms\Components\Select::make('title_id')
->relationship('title', 'name')
In the table a working
Tables\Columns\TextColumn::make('title.name'),
Tables\Columns\TextColumn::make('title.name'),
But this doesn't work in the form... I want to display only. Not allow change at a certain point,
Forms\Components\TextInput::make('title.name')
->label('Title'),

Forms\Components\TextInput::make('title.name')
->label('Title'),

Do I need to use a select and make it read only? Model
public function title(): BelongsTo
{
return $this->belongsTo(Title::class);
}
public function title(): BelongsTo
{
return $this->belongsTo(Title::class);
}
6 replies
FFilament
Created by ddoddsr on 6/27/2024 in #❓┊help
Use Enums in modifyQueryUsing for the ListRecord getTabs
I am using Enums in select on the form and in a selec filter but don't get how to use in a getTabs in the ListRecord page of my Resource. I was using another method and it worked fine but the enum is more sustainable. In this example the Enum 10 is labeled "Running"
return [
'all' => Tab::make('All'),
'Running' => Tab::make('Running')
->modifyQueryUsing(fn (Builder $query) => $query->where('status_id', 10))

// Not sure how to get the proper Enum here
//->modifyQueryUsing(fn (Builder $query) => $query->where('status_id', CampaignStatusEnum))
return [
'all' => Tab::make('All'),
'Running' => Tab::make('Running')
->modifyQueryUsing(fn (Builder $query) => $query->where('status_id', 10))

// Not sure how to get the proper Enum here
//->modifyQueryUsing(fn (Builder $query) => $query->where('status_id', CampaignStatusEnum))

namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
enum CampaignStatusEnum: int implements HasLabel
{
case New = 0;
case Ready = 1;
case Run = 10;
case Paused = 30;
case Ended = 40;

public function getLabel(): ?string
{
return match ($this) {
self::New => 'New',
self::Ready => 'Ready To Launch',
self::Run => 'Running',
self::Paused => 'Paused',
self::Ended => 'Ended',
};
}
}
namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
enum CampaignStatusEnum: int implements HasLabel
{
case New = 0;
case Ready = 1;
case Run = 10;
case Paused = 30;
case Ended = 40;

public function getLabel(): ?string
{
return match ($this) {
self::New => 'New',
self::Ready => 'Ready To Launch',
self::Run => 'Running',
self::Paused => 'Paused',
self::Ended => 'Ended',
};
}
}
the query should be ``` $query->where('status_id', CampaignStatusEnum::Run->value )
4 replies
FFilament
Created by ddoddsr on 6/19/2024 in #❓┊help
Use BulkAction's form field in action for each in bulk
Bulk action needs to get a client id to assign to each in the collection I see how to select a client. and how to each assign and save(). How to get the client->id from the Select and pass it it to the action? ```Tables\Actions\BulkAction::make('assign_to_client') ->form([ Forms\Components\Select::make('client_id') ->options(Client::pluck('name', 'id')), ]) ->action(fn (Collection $records) => $records->each( function ( $record, $get ) { //error. Value of type int is not callable $record->client_id = $get('client_id'); // Hardcoded works $record->client_id = 9; $record->save(); } ))
5 replies
FFilament
Created by ddoddsr on 6/17/2024 in #❓┊help
can selectColumn have a createForm
I'd like to use the selectColumn with a relationship and optionally show a createForm if the option should be added. Just a little '+' sign next to the option I'm getting the relationship via
SelectColumn::make('title_id')
->label('Title')
->options(Title::pluck('name', 'id')->toArray()),
SelectColumn::make('title_id')
->label('Title')
->options(Title::pluck('name', 'id')->toArray()),
4 replies
FFilament
Created by ddoddsr on 6/10/2024 in #❓┊help
Aggregating relationships use two sums and calculate the percentage.
I have two columns working for the Aggregating Relation but I don't see how to use the results in a third column calculation.
Tables\Columns\TextColumn::make('leads_sum_connected')
->sum('leads', 'connected')
->label('Connected'),

Tables\Columns\TextColumn::make('leads_sum_connection_request')
->sum('leads', 'connection_request')
->label('Connect Req'),
Tables\Columns\TextColumn::make('leads_sum_connected')
->sum('leads', 'connected')
->label('Connected'),

Tables\Columns\TextColumn::make('leads_sum_connection_request')
->sum('leads', 'connection_request')
->label('Connect Req'),
How to calc percent using the two above into connected_percent?
leads_sum_connected / leads_sum_connection_reques
leads_sum_connected / leads_sum_connection_reques

Tables\Columns\TextColumn::make('connected_percent')
->label('Connected %'),
Tables\Columns\TextColumn::make('connected_percent')
->label('Connected %'),
6 replies
FFilament
Created by ddoddsr on 6/3/2024 in #❓┊help
How to display in a resource table view the summary of the detail in a RelationManager
In a RelationManager on this resource I have stats I gather every week. I'd like to summarize these stats do some calcs and show in the table view of the original resource. Is this possible with standard tools Is this possible with custom tools / views? Is there a plugin? from the demo I don't think advanced tables does this. Can anyone point me in the right direction ?
8 replies
FFilament
Created by ddoddsr on 5/15/2024 in #❓┊help
table row grouping options
-- Can we cause the first Group to be open and the rest collasped by default? When User opens the table show Newest week detail, past weeks summary. --- I have the DESC order . --- I do see ->groupsOnly() which collapses them all
2 replies
FFilament
Created by ddoddsr on 11/10/2023 in #❓┊help
V2 to V3 Action with Form adapt to changes
What I am trying to do: Have an action button in a custom page that displays a form with a select and then calls a function with the result of the select What I did so far was working in V2, and I tried two more actions, Nted in the code comments
public function genWallAction(): Action
{
return Action::make('genWallPdf')
->label('Generate Wall PDF')
// Original working v2 action
// ->action('genWallPdf')

// from example
// ->action(Closure::fromCallable([$this, 'genWallPdf']))

//another try
->action(function (array $data) {
$this->genWallPdf($data);
})

->form([
Select::make('location')
->options(Location::query()->pluck('name', 'id'))
->required()
->default(1),
]);
}
public function genWallAction(): Action
{
return Action::make('genWallPdf')
->label('Generate Wall PDF')
// Original working v2 action
// ->action('genWallPdf')

// from example
// ->action(Closure::fromCallable([$this, 'genWallPdf']))

//another try
->action(function (array $data) {
$this->genWallPdf($data);
})

->form([
Select::make('location')
->options(Location::query()->pluck('name', 'id'))
->required()
->default(1),
]);
}
The button show up with {{ $this->genWallAction }} in the blade file. I get the error message: https://flareapp.io/share/47qKp0Bm
4 replies