BRACKETS-by-TRIAD / craftable-pro-docs

Craftable PRO is an admin panel for your Laravel project build with InertiaJS, Vue and TailwindCSS.
https://docs.craftable.pro
MIT License
7 stars 1 forks source link

Question about <Listing> component. #102

Open cengizbarul opened 1 month ago

cengizbarul commented 1 month ago

Hello, I return my data as json with fetch, I need to view the user and pull the data into it as a table, and I use your table component which is ready when pulling the data,

For example model user, notes from user model will come into the table.

How can I do this in the fastest way? I am currently using fetch but I think this is not the right method.

If you say compile on the homepage, let's say there is 100K+ data, if I index it to the homepage, this would not be very correct, I need to use paginate in any way, how should I follow the path?

cengizbarul commented 1 month ago

Even if I send data directly to the page with inertia, when I do an automatic search, for example http://127.0.0.1:8000/admin/players/view/10 returns to this address because I have this table as a compontent in the tab.

strstensky commented 1 month ago

Hello, the Listing component handles pagination, you just need to send paginated data from the backend. This means using ->paginate() in your Eloquent query. You can check the implementation in the index method of the generated controllers. With this approach, the page should not reload when a search is applied.

cengizbarul commented 1 month ago

Yes, but this is a problem if you use the table in , the search part does not work.

strstensky commented 1 month ago

Are you using the search in the same way as it is used in the generated Controllers and Requests?

In the controller you need to have:

QueryBuilder::for(YOUR_MODEL_CLASS)
->allowedFilters([
            AllowedFilter::custom('search', new FuzzyFilter(
                YOUR_FIELDS_TO_SEARCH_IN
            )),
        ])
->paginate();

In request you should have this rule:

'search' => ['sometimes', 'string'],

If I understand correctly, you're essentially trying to do the same thing as in the generated listings, so you should follow the implementation used there.