JN-Jones / visitor-log

A package for Laravel 4 to log all visitors
11 stars 8 forks source link

Laravel 4.2 - static Clear() fix when timestamps isn't used #2

Open ghost opened 10 years ago

ghost commented 10 years ago

Please update for Laravel 4.2 (change requirements on your composer.json), and correct Jones\VisitorLog\Visitor::clear(), as Laravel 4.2 don't use timestamps, change clear()by this :

public static function clear()
    {
        $instance = new static;
        $time = Config::get('visitor-log::onlinetime');

        return $instance->newQuery()->where('updated_at', '<', date('Y-m-d H:i:s', strtotime('-'.$time.' minutes')))->delete();
    }
JN-Jones commented 10 years ago

The clear function hasn't worked with any Laravel version (see the readme). That's why it's still a beta version.

About composer.json: I've updated it some time ago and it works on my localhost without problems. I didn't have much time lately to work with laravel so I'm not up to date with the recent changes ;)

ghost commented 10 years ago

At now, it's working on my Laravel 4.2, but only if the updated_at is a date, I'm working to make it work even if the updated_at is a timestamp.

JN-Jones commented 10 years ago

I'd make it a setting :P Not sure whether it's that easy to query the database to check whether it's a date or not. Haven't looked whether Eloquent allows to check this too.

Can you create a Pull Request when you've found a fix?

ghost commented 10 years ago

For sure.

ghost commented 10 years ago

Added the Pull Request as promised.