@@ -31,7 +31,8 @@ abstract class Grid implements Htmlable, GridInterface, GridButtonsInterface, Gr
3131 CreatesColumns,
3232 ConfiguresRoutes,
3333 AddsColumnFilters,
34- RendersButtons;
34+ RendersButtons,
35+ RendersGrid;
3536
3637 /**
3738 * Specify if the rows on the table should be clicked to navigate to the record
@@ -40,13 +41,6 @@ abstract class Grid implements Htmlable, GridInterface, GridButtonsInterface, Gr
4041 */
4142 protected $ linkableRows = false ;
4243
43- /**
44- * Specify if the footer section needs to be displayed
45- *
46- * @var bool
47- */
48- protected $ showFooter = false ;
49-
5044 /**
5145 * The id of the grid. Many grids can exist on the same page, but the ID has to be unique
5246 *
@@ -117,13 +111,6 @@ abstract class Grid implements Htmlable, GridInterface, GridButtonsInterface, Gr
117111 */
118112 protected $ tableColumns = [];
119113
120- /**
121- * Controls rendering or not, for the search form
122- *
123- * @var bool
124- */
125- protected $ shouldRenderSearchForm = true ;
126-
127114 /**
128115 * Create the grid
129116 *
@@ -149,17 +136,6 @@ public function create(array $params): GridInterface
149136 return $ this ;
150137 }
151138
152- /**
153- * Define rendering of the search form
154- *
155- * @return GridInterface
156- */
157- public function withoutSearchForm (): GridInterface
158- {
159- $ this ->shouldRenderSearchForm = false ;
160- return $ this ;
161- }
162-
163139 /**
164140 * Get the selected sort direction
165141 *
@@ -226,24 +202,6 @@ public function getName(): string
226202 return $ this ->name ;
227203 }
228204
229- /**
230- * If the grid should show a footer
231- *
232- * @return bool
233- */
234- public function shouldShowFooter (): bool
235- {
236- return $ this ->showFooter ;
237- }
238-
239- /**
240- * @param bool $showFooter
241- */
242- public function setShowFooter (bool $ showFooter ): void
243- {
244- $ this ->showFooter = $ showFooter ;
245- }
246-
247205 /**
248206 * Transform the name of the grid, to a short, identifier
249207 * Useful for route param names
@@ -320,37 +278,6 @@ protected function setGridDataItems(array $result): void
320278 }
321279 }
322280
323- /**
324- * Grid should render search form
325- *
326- * @return bool
327- */
328- public function shouldRenderSearchForm ()
329- {
330- return $ this ->shouldRenderSearchForm ;
331- }
332-
333- /**
334- * Render the search form on the grid
335- *
336- * @return string
337- * @throws \Throwable
338- */
339- public function renderSearchForm ()
340- {
341- $ params = func_get_args ();
342- $ data = [
343- 'colSize ' => $ this ->getGridToolbarSize ()[0 ], // size
344- 'action ' => $ this ->getSearchUrl (),
345- 'id ' => $ this ->getSearchFormId (),
346- 'name ' => $ this ->getGridSearchParam (),
347- 'dataAttributes ' => [],
348- 'placeholder ' => $ this ->getSearchPlaceholder (),
349- ];
350-
351- return view ($ this ->getGridSearchView (), array_merge ($ data , $ params ))->render ();
352- }
353-
354281 /**
355282 * Get the form id used for search
356283 *
@@ -445,45 +372,6 @@ public function toHtml()
445372 return $ this ->render ();
446373 }
447374
448- /**
449- * Render the grid as HTML on the user defined view
450- *
451- * @return string
452- * @throws \Throwable
453- */
454- public function render ()
455- {
456- return view ($ this ->getGridView (), $ this ->compactData (func_get_args ()))->render ();
457- }
458-
459- /**
460- * Specify the data to be sent to the view
461- *
462- * @param array $params
463- * @return array
464- * @throws \Exception
465- */
466- protected function compactData ($ params = [])
467- {
468- $ data = [
469- 'grid ' => $ this ,
470- 'columns ' => $ this ->processColumns ()
471- ];
472- return array_merge ($ data , $ this ->getExtraParams ($ params ));
473- }
474-
475- /**
476- * Any extra parameters that need to be passed to the grid
477- * $params is func_get_args() passed from render
478- *
479- * @param array $params
480- * @return array
481- */
482- public function getExtraParams ($ params )
483- {
484- return array_merge ($ this ->extraParams , $ params );
485- }
486-
487375 /**
488376 * Override this method and return a callback so that linkable rows are applied
489377 *
@@ -567,23 +455,4 @@ public function getHeaderClass(): string
567455 {
568456 return $ this ->getGridDefaultHeaderClass ();
569457 }
570-
571- /**
572- * Pass the grid on to the user defined view e.g an index page, along with any data that may be required
573- * Will dynamically switch between displaying the grid and downloading exported files
574- *
575- * @param string $viewName the view name
576- * @param array $data any extra data to be sent to the view
577- * @param string $as the variable to be sent to the view, representing the grid
578- *
579- * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\Response|\Illuminate\View\View
580- * @throws \Throwable
581- */
582- public function renderOn (string $ viewName , $ data = [], $ as = 'grid ' )
583- {
584- if ($ this ->getRequest ()->has ($ this ->getGridExportParam ())) {
585- return $ this ->exportHandler ->export ();
586- }
587- return view ($ viewName , array_merge ($ data , [$ as => $ this ]));
588- }
589458}
0 commit comments