pingpong-labs / admin

Laravel 5 Admin
https://packagist.org/packages/pingpong/admin
BSD 3-Clause "New" or "Revised" License
432 stars 114 forks source link

Admin Dashboard not available with Postgres #8

Closed noxify closed 10 years ago

noxify commented 10 years ago

Hi,

at first - thanks for this package!

I have the following environment setup

The installation of your package was successful.

I was able to go to the login page, but after login, I got the following error message

SQLSTATE[42883]: Undefined function: 7 ERROR: function left(timestamp without time zone, integer) does not exist LINE 1: ...ct sum("hits") as aggregate from "visitors" where LEFT(creat... ^ HINT: No function matches the given name and argument types. 
You might need to add explicit type casts. (SQL: select sum("hits") as aggregate from "visitors" where LEFT(created_at, 10) = LEFT(NOW(), 10)) (View: /Applications/MAMP/htdocs/ping-admin/vendor/pingpong/admin/src/views/index.blade.php)

I have modify the

vendor/pingpong/admin/src/Pingpong/Admin/Entities/Visitor.php

to the following

    public function scopeToday($query)
    {
        //return $query->whereRaw("left(created_at, 10) = left(NOW(), 10)");
    }

I can access the admin dashboard.

Do you have any idea, how we can fix this?

Thanks!

noxify commented 10 years ago

Hi,

after changing the function to:

public function scopeToday($query)
    {
        return $query->whereRaw("SUBSTRING(CONCAT(created_at, ''), 0, 10) = SUBSTRING(CONCAT(NOW(), ''), 0, 10)");
    }

it works fine with postgres :)