php - Carbon diffforhuman not working on DB raw -


this 1 works fine:

$news = newsfeed::all(); 

return is:

{     "new": [         {             "id": "nf_gi042g0493c389rt1z09",             "user_id": "cus_g530t786s1gvwlcj3nw1",             "newsfeedable_id": "sta_7f5ej6587n2523750czr",             "newsfeedable_type": "status",             "created_at": "2015-03-31 06:01:03",             "updated_at": "2015-03-31 06:01:03"         },         {             "id": "nf_0k625i8vp9sg22637a80",             "user_id": "cus_g530t786s1gvwlcj3nw1",             "newsfeedable_id": "cnt_df22v8dorg2k143n1288",             "newsfeedable_type": "contact",             "created_at": "2015-03-30 10:04:34",             "updated_at": "2015-03-30 10:04:34"         }     ] } 

==============

but this:

$news = db::select( db::raw(" select * `news_feed` ") ); 

note: mysql query fine, working perfectly

my code:

$x = $news->updated_at->diffforhumans(); echo $x; 

error:

call member function diffforhumans() on non-object

i did var_dump here result of db raw:

{       "new": [             {                 "id": "nf_gi042g0493c389rt1z09",                 "user_id": "cus_g530t786s1gvwlcj3nw1",                 "newsfeedable_id": "sta_7f5ej6587n2523750czr",                 "newsfeedable_type": "status",                 "created_at": "2015-03-31 06:01:03",                 "updated_at": "2015-03-31 06:01:03"             },             {                 "id": "nf_0k625i8vp9sg22637a80",                 "user_id": "cus_g530t786s1gvwlcj3nw1",                 "newsfeedable_id": "cnt_df22v8dorg2k143n1288",                 "newsfeedable_type": "contact",                 "created_at": "2015-03-30 10:04:34",                 "updated_at": "2015-03-30 10:04:34"             }         ] } 

eloquent , db raw var dump result 100% same.

why diffforhumans() not working on db raw?

if try var_dump updated_at using eloquent

var_dump($eloquent_news->updated_at);

{         "date": "2015-03-31 06:01:03.000000",         "timezone_type": 3,         "timezone": "utc"     } 

this actual result of updated_at render eloquent, don't know how make happen in db::raw. @ least know going on.

bottomline:

eloquent updated_at , db::raw not 100% same.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -