Pscl
Pscl
FFilament
Created by Pscl on 9/7/2024 in #❓┊help
How to Attach or create a polymorphic relation model to another model in the relation manager?
Hey all, How to Attach or create a polymorphic relation model to another model in the relation manager? In the relation manager there is the CreateAction and AttachAction. My goal is to have just one button and let the user search for an item and if no results, it suggest to add it. Did I miss out any references in documentation for this? https://filamentphp.com/docs/3.x/forms/fields/select#creating-a-new-option-in-a-modal this seems not to work for polymorphic many to many relations. THX!
2 replies
FFilament
Created by Pscl on 7/30/2024 in #❓┊help
How to use a Repeater with relation ship in an actions form?
I can't find how to set the model and relation for a Repeater in an actions form. Would be happy to get some hints on how to tell the repeater the Model and Relation to use to populate the data.
4 replies
FFilament
Created by Pscl on 7/21/2024 in #❓┊help
hover:text-white somehow not available on my filament.
No description
15 replies
FFilament
Created by Pscl on 6/27/2024 in #❓┊help
Using a page with HasFiltersForm and InteractsWithRecord or a dashboard as page
Hey all, I am trying to add a FilterForm to my page. But it seems like that It needs to be a dashboard page. But when I make it a dashboard page, I can't register it in my pages on my resource, because ::route is not provided on dashboard page. Any idea how to get out of this loop? 😄
3 replies
FFilament
Created by Pscl on 6/9/2024 in #❓┊help
Showing icons in Table Column Badge
Hey all,
Tables\Columns\TextColumn::make('types.name')->badge()->icon('types.icon')
Tables\Columns\TextColumn::make('types.name')->badge()->icon('types.icon')
Iam trying to accomplish this. As my types are stored in database and not as enum, how can I add icon within the badge that loads the icon from icon column in types table? Thanks!
10 replies
FFilament
Created by Pscl on 5/20/2024 in #❓┊help
Adding Custom Action to TopBar
Hey all,

//AppServiceProvider.php

FilamentView::registerRenderHook(
PanelsRenderHook::GLOBAL_SEARCH_AFTER,
function () {
$action = Action::make('sendIdea')
->label('moep')
->form([
TextInput::make('subject')->required(),
// RichEditor::make('body')->required(),
])
->action(function (array $data) {
// Handle the action logic here
dd($data);
});

return view('components.send-idea-button', compact('action'));
}
);

//send-idea-button.blade.php
<div>
{{ $action }}
</div>

//AppServiceProvider.php

FilamentView::registerRenderHook(
PanelsRenderHook::GLOBAL_SEARCH_AFTER,
function () {
$action = Action::make('sendIdea')
->label('moep')
->form([
TextInput::make('subject')->required(),
// RichEditor::make('body')->required(),
])
->action(function (array $data) {
// Handle the action logic here
dd($data);
});

return view('components.send-idea-button', compact('action'));
}
);

//send-idea-button.blade.php
<div>
{{ $action }}
</div>
The button is displayed at topbar, but the magic of opening the form is not happening. Which piece of the puzzle am I missing? Thanks for support!
3 replies
FFilament
Created by Pscl on 5/19/2024 in #❓┊help
How to load widgets only on specific pages/dashboards?
Hey all, I am trying to achieve multiple dashboards with different widgets. But somehow All widgets are loaded on all dashboards. Using getHeaderWidgets is just adding the widget of the array 2nd time on the page.
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
This is loading all widgets an all pages. If I remove it and add widgets here:
->widgets([
MonthlyExpenseChartWidget::class
// Widgets\AccountWidget::class,
// Widgets\FilamentInfoWidget::class,
])
->widgets([
MonthlyExpenseChartWidget::class
// Widgets\AccountWidget::class,
// Widgets\FilamentInfoWidget::class,
])
All of these widgets are loaded on every dashboard page. I am confused 😄 Thx for help
5 replies
FFilament
Created by Pscl on 5/15/2024 in #❓┊help
Modifying exporter to get grouped exports
<?php

namespace App\Filament\Exports;

use App\Models\TimeEntry;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;

class TimeEntryExporter extends Exporter
{
protected static ?string $model = TimeEntry::class;

public static function getColumns(): array
{
return [
ExportColumn::make('task_name'),
ExportColumn::make('total_duration_hours'),
];
}

public static function modifyQuery(Builder $query): Builder
{
return $query->select('task_name', DB::raw('SUM(duration_hours) as total_duration_hours'))
->groupBy('task_name');
}

public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your time entry export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';

if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}

return $body;
}
}
<?php

namespace App\Filament\Exports;

use App\Models\TimeEntry;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;

class TimeEntryExporter extends Exporter
{
protected static ?string $model = TimeEntry::class;

public static function getColumns(): array
{
return [
ExportColumn::make('task_name'),
ExportColumn::make('total_duration_hours'),
];
}

public static function modifyQuery(Builder $query): Builder
{
return $query->select('task_name', DB::raw('SUM(duration_hours) as total_duration_hours'))
->groupBy('task_name');
}

public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your time entry export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';

if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}

return $body;
}
}
` I do have a TimeEntries table. I want to create an exporter that exports the time entries grouped by name and it's duration in sum. But Exporter Fails. In my laravel.log file I get the error attached. Any idea how to achieve an grouped export?
1 replies
FFilament
Created by Pscl on 5/14/2024 in #❓┊help
Dashboard in SubNavigation
In my Resource I am trying to do setup a subNavigation with a Dashboard Item that gives me a link to a dashboard just for the record.

//Resource
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\Dashboard::class,
]);
}

public static function getPages(): array
{
return [
'dashboard' => Pages\Dashboard::route('/{record}/dashboard'),
];
}

//Page/Dashboard
class Dashboard extends BaseDashboard

//Resource
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\Dashboard::class,
]);
}

public static function getPages(): array
{
return [
'dashboard' => Pages\Dashboard::route('/{record}/dashboard'),
];
}

//Page/Dashboard
class Dashboard extends BaseDashboard
The error I get
Method App\Filament\Resources\ModelResource\Pages\Dashboard::route does not exist.
Method App\Filament\Resources\ModelResource\Pages\Dashboard::route does not exist.
Ofcourse... but any Idea how to get it working to utilize Dashboard as a SubNavigation Page for a specific record?
17 replies
FFilament
Created by Pscl on 5/14/2024 in #❓┊help
Combining Clusters with Pages? Or on the wrong way?
Hey all, https://demo.filamentphp.com/shop/products/products Here we do see a cluster... but I am trying to accomplish something slightly different and asking what would we the best way to set it up? I have Model and the ViewModel Page should have a cluster with following Navigation items: 1. Dashboard 2. Informations 3. RelatedModel1 4. RelatedModel2 My head is stucking on how to accomplish this. Is this possible with Clusters? Or do I need to go a different route? Thanks!
3 replies
FFilament
Created by Pscl on 5/12/2024 in #❓┊help
How to get and use current model of view page within a widget?
protected function getData(): array {
$currentModel = ...?
//...
}
protected function getData(): array {
$currentModel = ...?
//...
}
I want t load stats of a model... hmm. thanks!
12 replies