44
55use Illuminate \Database \Eloquent \Builder ;
66use Illuminate \Database \Query \Builder as QueryBuilder ;
7+ use Symfony \Component \VarDumper \VarDumper ;
78
89class Dumper
910{
1011 /**
11- * Dump the passed variables and end the script .
12+ * Throws a message with an SQL query .
1213 *
1314 * @see https://gist.github.com/Ellrion/561fc48894a87b853917e0a5cec83181#file-helper-php
1415 *
1516 * @param $query
1617 * @param bool $is_short
17- * @param bool $is_return
18+ *
19+ * @return void
20+ */
21+ public function sqlDd ($ query , bool $ is_short = false ): void
22+ {
23+ $ this ->sqlDump ($ query , $ is_short );
24+
25+ exit (1 );
26+ }
27+
28+ /**
29+ * Displays a message with an SQL query.
30+ *
31+ * @see https://gist.github.com/Ellrion/561fc48894a87b853917e0a5cec83181#file-helper-php
32+ *
33+ * @param $query
34+ * @param bool $is_short
35+ *
36+ * @return array|string|void
37+ */
38+ public function sqlDump ($ query , bool $ is_short = false ): void
39+ {
40+ $ data = $ this ->sql ($ query , $ is_short );
41+
42+ VarDumper::dump ($ data );
43+ }
44+
45+ /**
46+ * Returns SQL query.
47+ *
48+ * @param $query
49+ * @param bool $is_short
1850 *
1951 * @return array|string
2052 */
21- public function ddSql ($ query , bool $ is_short = false , bool $ is_return = false )
53+ public function sql ($ query , bool $ is_short = false )
2254 {
2355 $ query = $ this ->prepareQuery ($ query );
2456
@@ -28,13 +60,7 @@ public function ddSql($query, bool $is_short = false, bool $is_return = false)
2860
2961 $ raw = $ this ->getRaw ($ sql , $ bindings );
3062
31- $ data = $ this ->getData ($ is_short , $ sql , $ query ->getRawBindings (), $ raw );
32-
33- if ($ is_return ) {
34- return $ data ;
35- }
36-
37- dd ($ data );
63+ return $ this ->getData ($ is_short , $ sql , $ query ->getRawBindings (), $ raw );
3864 }
3965
4066 protected function prepareQuery ($ query ): QueryBuilder
0 commit comments