File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
src/app/Library/CrudPanel/Traits Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,36 @@ trait Buttons
1010 // BUTTONS
1111 // ------------
1212
13- // TODO: $this->crud->reorderButtons('stack_name', ['one', 'two']);
13+ /**
14+ * Reorder buttons to the CRUD table view.
15+ *
16+ * @param string $stack Stack where the buttons belongs. Options: top, line, bottom.
17+ * @param array $buttons Name of the buttons. ['update', 'delete', 'show']
18+ */
19+ public function reorderButtons ($ stack , $ buttons )
20+ {
21+ $ newBtns = collect ([]);
22+
23+ $ this ->buttons ()->each (function ($ btn ) use ($ stack , $ newBtns ) {
24+ if ($ btn ->stack != $ stack ) {
25+ $ newBtns ->push ($ btn );
26+ }
27+ });
28+
29+ collect ($ buttons )->each (function ($ btnKey ) use ($ newBtns ) {
30+ $ btnInstance = $ this ->buttons ()->filter (function ($ btn ) use ($ btnKey ) {
31+ return $ btn ->name == $ btnKey ;
32+ })->first ();
33+
34+ if (! $ btnInstance ) {
35+ abort (500 , 'Sorry, button cannot be found ' );
36+ }
37+
38+ $ newBtns ->push ($ btnInstance );
39+ });
40+
41+ $ this ->setOperationSetting ('buttons ' , $ newBtns );
42+ }
1443
1544 /**
1645 * Add a button to the CRUD table view.
You can’t perform that action at this time.
0 commit comments