Laravel timestamp carbon non-object -


hi want create own timestamp work carbon diffin function problem getting "call member function diffinseconds() on non-object" tough timestamp made proper?.

public function up() {     schema::create('global_limits', function(blueprint $table) {         $table->increments('id');         $table->integer('user_id');         $table->integer('c_limiter');         $table->timestamp('time_comment');         $table->timestamps('');     }); } 

here how create timespam time_comment

  $first_limit = new limiter;   $first_limit->c_limiter = 1;   $first_limit->user_id = $id;   $first_limit->time_comment = new datetime;    $first_limit->save(); 

when

$user = user::find(1)->limits; 

echo $user->time_comment 2014-04-09 18:20:55 when echo $user->time_comment->diffinseconds(); <- error

call member function diffinseconds() on non-object on proper timestamp. 

strange thing when make same thing created_at , uptaded_at works fine.

echo $user->created_at->diffinseconds(); <-- works fine shows diffrence in seconds

i know can use updated_at want use time_comment have reasons that.

i don't want diffforhumans because goal use

    if($user->time_comment->diffinseconds() > 500) {do something)else {do this} 

laravel treats created_at, updated_at , deleted_at carbon instances default. need add following user model

public function getdates() {     return array('created_at', 'updated_at', 'time_comment'); } 

this tells laravel treat columns in array carbon instances.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -