framework icon indicating copy to clipboard operation
framework copied to clipboard

[Request] Eloquent shouldn't override timestamps if they have been sent.

Open abishekrsrikaanth opened this issue 13 years ago • 4 comments

Eloquent shouldn't override timestamps if they have been sent. An example of the same is below:

//Model Code
<?php 
class User extends Eloquent
{
    public $timestamps = true;
    public $tables = 'users';
    public $connection = 'new_db';
    protected $guarded=array();
}

//Controller Code
class UserController extends BaseController
{
    public function migrateUsers(){
        $users = DB:connection('old_db')->table('users')->get();
        foreach($users as $user){
            User::create(array('username'=>$user->username,
                'password'=>$user->password,
                'role' => $user->role,
                'created_at'=>$user->created_at
            ));
        }
    }
}

abishekrsrikaanth avatar May 14 '13 15:05 abishekrsrikaanth

+1

roggel2000 avatar May 14 '13 15:05 roggel2000

+1 for data recovery, import & more

Spir avatar May 14 '13 15:05 Spir

Should be easy with the recently added array_add helper (which was added for about the same purpose)

JoostK avatar May 14 '13 15:05 JoostK

+1

schickling avatar May 15 '13 05:05 schickling