File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 22
33namespace Mediconesystems \LivewireDatatables ;
44
5+ use Closure ;
56use Illuminate \Support \Facades \DB ;
67use Illuminate \Support \Str ;
78use Mediconesystems \LivewireDatatables \Http \Livewire \LivewireDatatable ;
@@ -92,11 +93,25 @@ public static function raw($raw)
9293 return $ column ;
9394 }
9495
95- public static function callback ($ columns , $ callback , $ params = [])
96- {
96+ /**
97+ * Make a callback function.
98+ *
99+ * @param $columns string The (comma separated) columns that should be retrieved from the database.
100+ * Is being translated directly into the `.sql`.
101+ * @param $callback Closure A callback that defines how the retrieved columns are processed.
102+ * @param $params Array Optional additional parameters that are passed to the given Closure.
103+ * @param $callbackName string Optional string that defines the 'name' of the column.
104+ * Leave empty to let livewire autogenerate a distinct value.
105+ */
106+ public static function callback (
107+ string $ columns ,
108+ Closure $ callback ,
109+ array $ params = [],
110+ ?string $ callbackName = null
111+ ) {
97112 $ column = new static ;
98113
99- $ column ->name = 'callback_ ' . crc32 (json_encode (func_get_args ()));
114+ $ column ->name = 'callback_ ' . ( $ callbackName ?? crc32 (json_encode (func_get_args () )));
100115 $ column ->callback = $ callback ;
101116 $ column ->additionalSelects = is_array ($ columns ) ? $ columns : array_map ('trim ' , explode (', ' , $ columns ));
102117 $ column ->params = $ params ;
You can’t perform that action at this time.
0 commit comments