columns = {{ rows }} } /** * Set the links/routes. This are referenced using named routes, for the sake of simplicity * * @return void */ public function setRoutes() { // searching, sorting and filtering $this->setIndexRouteName('{{ routeRoot }}.index'); // crud support $this->setCreateRouteName('{{ routeRoot }}.create'); $this->setViewRouteName('{{ routeRoot }}.show'); $this->setDeleteRouteName('{{ routeRoot }}.destroy'); // default route parameter $this->setDefaultRouteParameter('{{ modelPk }}'); } /** * Return a closure that is executed per row, to render a link that will be clicked on to execute an action * * @return Closure */ public function getLinkableCallback(): Closure { return function ($gridName, $item) { return route($this->getViewRouteName(), [$gridName => $item->{{ modelPk }}]); }; } /** * Configure rendered buttons, or add your own * * @return void */ public function configureButtons() { // call `addRowButton` to add a row button // call `addToolbarButton` to add a toolbar button // call `makeCustomButton` to do either of the above, but passing in the button properties as an array // call `editToolbarButton` to edit a toolbar button // call `editRowButton` to edit a row button // call `editButtonProperties` to do either of the above. All the edit functions accept the properties as an array } /** * Returns a closure that will be executed to apply a class for each row on the grid * The closure takes two arguments - `name` of grid, and `item` being iterated upon * * @return Closure */ public function getRowCssStyle(): Closure { return function ($gridName, $item) { // e.g, to add a success class to specific table rows; // return $item->{{ modelPk }} % 2 === 0 ? 'table-success' : ''; return ""; }; } }