Search code examples
phplaravel-4models

Laravel error model using function attributesToArray with created_at


I'm trying to clone a model using the function attributesToArray; but, I've got a problem with dates created_at = '0000-00-00 00:00:00.000000'.

This is my code:

$user2 = new User2(); 
$user2->fill($user->attributesToArray());

Exception returns me the message:

InvalidArgumentException Unexpected data found. Trailing data


Solution

  • The answer is change the model:

    public function getDates()
    {
        return array();
    }
    

    http://laravel.com/docs/4.2/eloquent#date-mutators