reppair
reppair
FFilament
Created by reppair on 10/31/2024 in #❓┊help
Component with actions in a loop?
Seems like I have to render the <x-filament-actions::modals /> for each component having actions in my loop, which causes couple of problems: - the action modal becomes a child element, so all clicks on it bubble up and have to be dealth with - it renders the modals form in the DOM as many items there are in the loop Can't I load the actions to the <x-filament-actions::modals /> of my parent component which also has it's own actions?
2 replies
FFilament
Created by reppair on 10/30/2024 in #❓┊help
Filament Notifications and `wire:navigate`
Hi! Quick question, maybe someone had this issue before, can find anything about it. Here is what's up...
// in root layout /layouts/app.blade.php
<livewire:notifications />

// two routes using standard Livewire components
Route::get('/goals', ListGoals::class);
Route::get('/goals/{goal}', ViewGoal::class);

// List Goals component and the create action look like
class ListGoals extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;

#[Computed]
public function goals(): Collection
{
return auth()->user()->goals;
}

public function createAction(): CreateAction
{
return CreateAction::make()
->model(Goal::class)
->form(GoalForm::schema())
->mutateFormDataUsing(function (array $data) {
$data['user_id'] = auth()->id();
return $data;
});
}

// ...
}
// in root layout /layouts/app.blade.php
<livewire:notifications />

// two routes using standard Livewire components
Route::get('/goals', ListGoals::class);
Route::get('/goals/{goal}', ViewGoal::class);

// List Goals component and the create action look like
class ListGoals extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;

#[Computed]
public function goals(): Collection
{
return auth()->user()->goals;
}

public function createAction(): CreateAction
{
return CreateAction::make()
->model(Goal::class)
->form(GoalForm::schema())
->mutateFormDataUsing(function (array $data) {
$data['user_id'] = auth()->id();
return $data;
});
}

// ...
}
So when I use the action to create a goal, the notification shows correctly, the component re-renders the goals, I use a link to the view goal route that has wire:navigate on it...
<a href="{{ route('goals.show', $goal) }}" wire:navigate class="block">...</a>
<a href="{{ route('goals.show', $goal) }}" wire:navigate class="block">...</a>
When the view component renders, the notification disappears, then I would go back, and the same "Goal created" notification shows.
2 replies
FFilament
Created by reppair on 4/23/2024 in #❓┊help
Markdown Editor with Spatie's media library.
Anyone have done that yet? I've tried to lookup some ready solutions but seems nobody needs/discuss/use that. Here are some advantages to it: - would allow media authorization management trough say S3 temporary signed urls or local disk and custom route to serve the files. This is needed when the files should be private in general, but still accessible for some users to render on a private page - benefit from all the media library server side processing of files - easily listing all resources used in a certain scope Any thoughts on it, suggestions, pros/cons.. any feedback is welcome.
1 replies
FFilament
Created by reppair on 4/10/2024 in #❓┊help
Newbie question about reusing filters
Just under 10 hours using Fillament, so maybe obvious and I am missing it, but is there a common Filament way of reusing filters or this is just fine?
<?php

namespace App\Filament\Resources\Shared\Filters;

use Filament\Tables\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;

abstract class UpcomingFilter
{
public static function make(): Filter
{
return Filter::make('upcoming')
->translateLabel('Upcoming')
->query(fn (Builder $query): Builder => $query->where('published_at', '>', now()))
->toggle();
}
}
<?php

namespace App\Filament\Resources\Shared\Filters;

use Filament\Tables\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;

abstract class UpcomingFilter
{
public static function make(): Filter
{
return Filter::make('upcoming')
->translateLabel('Upcoming')
->query(fn (Builder $query): Builder => $query->where('published_at', '>', now()))
->toggle();
}
}
Basically creating a class and pulling it from there in any resource which uses that filter.
5 replies