ddoddsr
ddoddsr
FFilament
Created by ddoddsr on 1/16/2025 in #❓┊help
without events with import model
Can I use the importer without it issuing events that my Observer will pickup? I see the
$user = User::withoutEvents(function () {
User::findOrFail(1)->delete();

return User::find(2);
});
$user = User::withoutEvents(function () {
User::findOrFail(1)->delete();

return User::find(2);
});
but don't know where to apply it. Is there a config option?
2 replies
FFilament
Created by ddoddsr on 1/9/2025 in #❓┊help
When dispatching a job and passing a model ... Is model beibng create or Update
I am passing the $record to the job but how do I know if it is a new record or an update? \App\Jobs\AirtableSync::dispatch($record); in job:
public function __construct( public Lead $record )
{
dd($record);
}
public function __construct( public Lead $record )
{
dd($record);
}
I could pass a value for example $is_new
But is there a method that tells me if a record is newly created?
11 replies
FFilament
Created by ddoddsr on 12/24/2024 in #❓┊help
Add laravel-comments to a RelationManager.
I followed the talk that Dan Harrin and Freek had about two years ago about Spaties laravel-comments in Filament v2. Also saw the v2 trick for this. I made changes to the examples to make it work on FilamentV3 and I made some real progress, showing thc comments connected to a Resourcewith a widget. There is also a CommentsResource which I have add will upon request. However, now I need the Comments on a RelationManager and don't see how to get the Widget working on a RelationManager. Given the simplicity of the Widget what can I do with a page or livewire component? This is a paid plugin so no channel? install laravel-client and the livewire plugin In App\Providers\AppServiceProvider. boot method
Filament::registerRenderHook(
PanelsRenderHook::STYLES_AFTER,
fn (): string => Blade::render('@laravelCommentsLivewireStyles'),
);

Filament::registerRenderHook(
PanelsRenderHook::SCRIPTS_AFTER,
fn (): string => Blade::render('@laravelCommentsLivewireScripts'),
);
Filament::registerRenderHook(
PanelsRenderHook::STYLES_AFTER,
fn (): string => Blade::render('@laravelCommentsLivewireStyles'),
);

Filament::registerRenderHook(
PanelsRenderHook::SCRIPTS_AFTER,
fn (): string => Blade::render('@laravelCommentsLivewireScripts'),
);
Then in the model
use Spatie\Comments\Models\Concerns\HasComments;


use HasComments;
...
public function commentableName(): string
{
return $this->first_name .' ' .$this->last_name ;
}
public function commentUrl(): string
{
return '';
}
use Spatie\Comments\Models\Concerns\HasComments;


use HasComments;
...
public function commentableName(): string
{
return $this->first_name .' ' .$this->last_name ;
}
public function commentUrl(): string
{
return '';
}
Widget
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class Comments extends Widget
{
protected static string $view = 'filament.widgets.comments';

public Model $record;

public function getColumnSpan(): int | string | array
{
return $this->columnSpan;
}


}
<?php

namespace App\Filament\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class Comments extends Widget
{
protected static string $view = 'filament.widgets.comments';

public Model $record;

public function getColumnSpan(): int | string | array
{
return $this->columnSpan;
}


}
widgit view
<x-filament-widgets::widget>
@if($record)
<x-filament::section>
<livewire:comments :model="$record" />
</x-filament::section>
@endif
</x-filament-widgets::widget>
<x-filament-widgets::widget>
@if($record)
<x-filament::section>
<livewire:comments :model="$record" />
</x-filament::section>
@endif
</x-filament-widgets::widget>
All of the above works in a resource when I add the widget to getWidgets() This does not work in the RelationManager getFooterWidgets() Or getWidgets()
3 replies
FFilament
Created by ddoddsr on 12/14/2024 in #❓┊help
How Add a widget to relationManager form
Is there a way to add a widget to the forms of a RelationManager? I have attached a widget to a resource form through the EditPage:
protected function getFooterWidgets(): array {
return [
\App\Filament\Widgets\Comments::class
];
}
protected function getFooterWidgets(): array {
return [
\App\Filament\Widgets\Comments::class
];
}
This works so I added this method to the RelationManager. no error and no widget. Looking in Filament RelationManager.php there is no mention of widgets like there is in Resource.php . So what to try next?
7 replies
FFilament
Created by ddoddsr on 12/11/2024 in #❓┊help
to update a field in one livewire component from another lw component.
I structured a form with Splits and Sections to make the layout I want. ( I'm sure there are other better ways to do that.) These call Livewire:make(..) and all is mostly nice looking for my purposes. I would like an action in one livewire component to update a textbox in another livewire component. Is this the job of $set() & $get()? $livewire? I dd($livewire) and everything must be in there... I see the keys I have assigned to various components, so I must be able to access and set them. What must I do to assign a value to a field with a specfic key in another component?
3 replies
FFilament
Created by ddoddsr on 12/10/2024 in #❓┊help
poll() discards mount data
Appears that adding poll() to the table causes the the $record in mount to become null after about 2s. The table rows are shown then after about 2s it throws an error. Attempt to read property "id" on null
At first I thought it was the Poll nterval but then changed it to a longer value and the error still happens after 2s. When both the ->where('campaign_contact_id', $this->record->id ) and poll(2) there is an error. Without one or the other, no error
class ViewContact extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;

protected ?Model $record = null;

public function mount ($record = null) {
$this->record = $record;
// dd($this->record) shows the data;
}

public function table(Table $table): Table
{
return $table
->poll(6)
->query(
Conversation::query()
// error on line below
->where('campaign_contact_id', $this->record->id )
)
->columns([
TextColumn::make('name'),
]);
}

public function render(): View
{
return view('livewire.view-contact');
}
}
class ViewContact extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;

protected ?Model $record = null;

public function mount ($record = null) {
$this->record = $record;
// dd($this->record) shows the data;
}

public function table(Table $table): Table
{
return $table
->poll(6)
->query(
Conversation::query()
// error on line below
->where('campaign_contact_id', $this->record->id )
)
->columns([
TextColumn::make('name'),
]);
}

public function render(): View
{
return view('livewire.view-contact');
}
}
5 replies
FFilament
Created by ddoddsr on 12/6/2024 in #❓┊help
footerActions run when modal open and close
And both actions run when I click one of them. Even with out the ->schema section. This is in a Relationanager :
public function form(Form $form): Form
{
return $form->schema(static::formSchema());
}

public static function formSchema(): array
{
return [
Split::make([
Section::make()
->schema([
static::getContactInboxConversation(),
])
->footerActions([
Action::make('previous_action')
->action(logger('previous_action')),
Action::make('next_action')
->action(logger('next_action')),
])
->extraAttributes(['class'=>'no-padding'])
->id('reviewSection'),
])
];
}
public function form(Form $form): Form
{
return $form->schema(static::formSchema());
}

public static function formSchema(): array
{
return [
Split::make([
Section::make()
->schema([
static::getContactInboxConversation(),
])
->footerActions([
Action::make('previous_action')
->action(logger('previous_action')),
Action::make('next_action')
->action(logger('next_action')),
])
->extraAttributes(['class'=>'no-padding'])
->id('reviewSection'),
])
];
}
20 replies
FFilament
Created by ddoddsr on 12/4/2024 in #❓┊help
Hints of methods to use:
No description
7 replies
FFilament
Created by ddoddsr on 12/3/2024 in #❓┊help
remove padding on section
I'm trying to remove the padding on a form section useing:
->extraAttributes(['class'=>'no-padding'])
->extraAttributes(['class'=>'no-padding'])

and adding to my theme.css
.no-padding {
padding: 0rem;
}
.no-padding {
padding: 0rem;
}
Or remove the "p-6" in the section content fi-section-content p-6 .
4 replies
FFilament
Created by ddoddsr on 11/30/2024 in #❓┊help
How to open custom page from relation manager
I can open page from a resource row with an Action in
table->actions([Tables\Actions\Action::make('Stats')
->url(fn(Client $record): string => self::getUrl('stats-monthly', ['record' => $record]))
table->actions([Tables\Actions\Action::make('Stats')
->url(fn(Client $record): string => self::getUrl('stats-monthly', ['record' => $record]))
and
public function getPages(): array
{
return [
'stats-monthly' => Pages\MonthlyStats::route('/{record}/monthly-stats'),
public function getPages(): array
{
return [
'stats-monthly' => Pages\MonthlyStats::route('/{record}/monthly-stats'),
But how to do this in ResourceManager? I want to open a Custom page from an action in in the InboxRelationManager which is on the Client.
->actions([
Tables\Actions\Action::make('work')
->url(fn(CampaignContact $record): string => self::getUrl('work', ['record' => $record])),
->actions([
Tables\Actions\Action::make('work')
->url(fn(CampaignContact $record): string => self::getUrl('work', ['record' => $record])),
and
public function getPages(): array
{
return [
'work' => ManageThread::route('/work'),
public function getPages(): array
{
return [
'work' => ManageThread::route('/work'),
. and I get error \InboxRelationManager::getUrl does not exist
5 replies
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