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 ;
@@ -97,11 +98,25 @@ public static function raw($raw)
9798 return $ column ;
9899 }
99100
100- public static function callback ($ columns , $ callback , $ params = [])
101- {
101+ /**
102+ * Make a callback function.
103+ *
104+ * @param $columns string The (comma separated) columns that should be retrieved from the database.
105+ * Is being translated directly into the `.sql`.
106+ * @param $callback Closure A callback that defines how the retrieved columns are processed.
107+ * @param $params Array Optional additional parameters that are passed to the given Closure.
108+ * @param $callbackName string Optional string that defines the 'name' of the column.
109+ * Leave empty to let livewire autogenerate a distinct value.
110+ */
111+ public static function callback (
112+ string $ columns ,
113+ Closure $ callback ,
114+ array $ params = [],
115+ ?string $ callbackName = null
116+ ) {
102117 $ column = new static ;
103118
104- $ column ->name = 'callback_ ' . crc32 (json_encode (func_get_args ()));
119+ $ column ->name = 'callback_ ' . ( $ callbackName ?? crc32 (json_encode (func_get_args () )));
105120 $ column ->callback = $ callback ;
106121 $ column ->additionalSelects = is_array ($ columns ) ? $ columns : array_map ('trim ' , explode (', ' , $ columns ));
107122 $ column ->params = $ params ;
You can’t perform that action at this time.
0 commit comments