coolsam726 / jetstream-inertia-generator

Laravel 8 Admin CRUD generator built with Jetstream, Inertia js, Vue 3 and Tailwindcss 2
MIT License
119 stars 30 forks source link

what is index action in controller in API being used for #48

Closed abhitheawesomecoder closed 2 years ago

abhitheawesomecoder commented 2 years ago

what is index action in controller in API being used for?

public function index(IndexStore $request) { $query = Store::query(); // You can extend this however you want. $cols = [ Column::name('id')->title('Id')->sort()->searchable(), Column::name('location_name')->title('Location Name')->sort()->searchable(), Column::name('address_1')->title('Address 1')->sort()->searchable(), Column::name('address_2')->title('Address 2')->sort()->searchable(), Column::name('city')->title('City')->sort()->searchable(), Column::name('province')->title('Province')->sort()->searchable(), Column::name('email')->title('Email')->sort()->searchable(), Column::name('phone_no')->title('Phone No')->sort()->searchable(), Column::name('updated_at')->title('Updated At')->sort()->searchable(),

        Column::name('actions')->title('')->raw()
    ];
    $data = Pagetables::of($query)->columns($cols)->make(true);
    return $this->api->success()->message("List of Stores")->payload($data)->send();
}

public function dt(Request $request) {
    $query = Store::query()->select(Store::getModel()->getTable().'.*'); // You can extend this however you want.
    return $this->repo::dt($query);
}
rakoi commented 2 years ago

it returns the default columns for the datatable for the respective models

abhitheawesomecoder commented 2 years ago

But when this action is called?

I can't find any event

On Wed, Feb 9, 2022, 3:57 PM bryan rakoi @.***> wrote:

it returns the default columns for the datatable for the respective models

— Reply to this email directly, view it on GitHub https://github.com/coolsam726/jetstream-inertia-generator/issues/48#issuecomment-1033604720, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6DATQHNTV6I6TEYK3XXZDU2I6RBANCNFSM5NZ5HXTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

coolsam726 commented 2 years ago

Hi @abhitheawesomecoder, Initially it was being used to actually render the Datatables, but since we moved to using Yajra datatables, this index function now is used mainly for fetching paginated lists of models and searching the models. If you check closely you will realize that all the InfiniteSelect input components call this method (e.g route('api.roles.index')) in order to fetch a paginated list of models, while at the same time offering search. The $cols variable sets the fields which can be searched within the model. You can even set relationships using dots. I hope this helps.