How to use Slug
abbasmashaddy72 opened this issue · 5 comments
What I want to achieve?
-
I have Tickets in My Project which has status I would Like to use
public static ?string $slug = 'kanban/{project}';
So that I can identify the for which Project the user is seeing the Kanban I get the all the tickets for it? -
I have These Models:
Status: HasMany tickets | BelongsTo projects
Ticket: BelongsTo status | BelongsTo projects
Project: HasMany tickets
How can I achieve this?
I'm also trying to achieve this by following your video:
Kanban Page:
<?php
namespace App\Filament\Pages;
use App\Models\Ticket;
use App\Models\TicketStatus;
use Illuminate\Support\Collection;
use Mokhosh\FilamentKanban\Pages\KanbanBoard;
class Kanban extends KanbanBoard
{
protected static string $recordTitleAttribute = 'name';
protected static string $recordStatusAttribute = 'status_id';
protected function records(): Collection
{
return Ticket::where('project_id', 1)->get();
}
protected function statuses(): Collection
{
return TicketStatus::all()->pluck('name', 'id');
}
}
Error:
Mokhosh\FilamentKanban\Pages\KanbanBoard::filterRecordsByStatus(): Argument #2 ($status) must be of type array, string given, called in /home/abbasmashaddy72/Documents/Sites/Dynamic/manage-project/vendor/mokhosh/filament-kanban/src/Pages/KanbanBoard.php on line 54
Package Version
3.0
PHP Version
PHP 8.2
Laravel Version
v10.10
That's not a correct slug
. Slugs cannot contain wildcards. You can only change the page uri by overriding the slug.
One way to achieve this would be to have a query string like this
yourpanel.test/project-kanban?id=2
Then in your records
method you can have this:
return Ticket::where('project_id', request()->query('id'))->get();
Also, the error that you're getting is because you're not returning the correct format from your statuses
method.
Check the readme and the videos and match your format accordingly.
Okay what about the error i am reciving
Also, the error that you're getting is because you're not returning the correct format from your statuses method.
Check the readme and the videos and match your format accordingly.
@abbasmashaddy72 did you ever figure this out? I'm running into both the same issues as you.
First, I can't route to a project because Mokhosh\FilamentKanban\Pages\KanbanBoard
doesn't extend the Filament\Resources\Pages\Page
class. I suppose I could use a query string if required though.
Second, I'm running into the same issue with statuses override requiring an array but the method insists on a Illuminate\Support\Collection
.
@ryanmortier, for the statuses method, you would just need to collect the array and map it to return the expected format.
for the routing issue, please create a new issue and tell me more about your ideal api, and i will consider it for v3.