Support the ongoing development of Laravel.io →
Installation Configuration Architecture

As L5 seems to be making a lot of changes I find that I can't replicate the event code below.

Cant = Not sure where/what to put.

This code used to live in a Filter or a AppServiceProvider.

Any advice people?

Event::listen('illuminate.query', function($query, $bindings, $time, $name) { $data = compact('bindings', 'time', 'name');

        // Format binding data for sql insertion
        foreach ($bindings as $i => $binding)
        {
            if ($binding instanceof \DateTime)
            {
                $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
            }
            else if (is_string($binding))
            {
                $bindings[$i] = "'$binding'";
            }
        }

        // Insert bindings into query
        $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
        $query = vsprintf($query, $bindings);

        //Log::info($query, $data);
        error_log($query, $data);
    });
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

qazjayp99 qazjayp99 Joined 27 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.