Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Slug #10

Closed
abbasmashaddy72 opened this issue Feb 14, 2024 · 5 comments
Closed

How to use Slug #10

abbasmashaddy72 opened this issue Feb 14, 2024 · 5 comments
Labels
question Further information is requested

Comments

@abbasmashaddy72
Copy link

abbasmashaddy72 commented Feb 14, 2024

What I want to achieve?

  1. 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?

  2. 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

@abbasmashaddy72 abbasmashaddy72 added the bug Something isn't working label Feb 14, 2024
@mokhosh mokhosh added question Further information is requested and removed bug Something isn't working labels Feb 15, 2024
@mokhosh
Copy link
Owner

mokhosh commented Feb 15, 2024

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.

@abbasmashaddy72
Copy link
Author

Okay what about the error i am reciving

@mokhosh
Copy link
Owner

mokhosh commented Feb 15, 2024

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.

@mokhosh mokhosh closed this as completed Feb 15, 2024
@ryanmortier
Copy link
Contributor

ryanmortier commented Apr 10, 2024

@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.

@mokhosh
Copy link
Owner

mokhosh commented Apr 10, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants