Conditions | 2 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function boot() |
||
21 | { |
||
22 | QueryBuilder::macro('toRawSql', function () { |
||
23 | /** |
||
24 | * @var $this QueryBuilder |
||
25 | */ |
||
26 | $sql = $this->toSql(); |
||
27 | $bindings = $this->getBindings(); |
||
28 | $bindings = $this->getConnection()->prepareBindings($bindings); |
||
29 | $bindings = array_map(function ($binding) { |
||
30 | return is_numeric($binding) |
||
31 | ? $binding |
||
32 | : "'" . addslashes($binding) . "'"; |
||
33 | }, $bindings); |
||
34 | |||
35 | return sprintf(str_replace('?', '%s', $sql), ...$bindings); |
||
36 | }); |
||
37 | |||
38 | EloquentBuilder::macro('toRawSql', function () { |
||
39 | /** |
||
40 | * @var $this EloquentBuilder |
||
41 | */ |
||
42 | return $this->toBase()->toRawSql(); |
||
43 | }); |
||
46 |