{"action":"closed","issue":{"url":"https://api.github.com/repos/laravel/lumen-framework/issues/754","repository_url":"https://api.github.com/repos/laravel/lumen-framework","labels_url":"https://api.github.com/repos/laravel/lumen-framework/issues/754/labels{/name}","comments_url":"https://api.github.com/repos/laravel/lumen-framework/issues/754/comments","events_url":"https://api.github.com/repos/laravel/lumen-framework/issues/754/events","html_url":"https://github.com/laravel/lumen-framework/issues/754","id":311923878,"number":754,"title":"Lumen seeder mysql timestamp problem","user":{"login":"Smilefish2","id":6111039,"avatar_url":"https://avatars0.githubusercontent.com/u/6111039?v=4","gravatar_id":"","url":"https://api.github.com/users/Smilefish2","html_url":"https://github.com/Smilefish2","followers_url":"https://api.github.com/users/Smilefish2/followers","following_url":"https://api.github.com/users/Smilefish2/following{/other_user}","gists_url":"https://api.github.com/users/Smilefish2/gists{/gist_id}","starred_url":"https://api.github.com/users/Smilefish2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Smilefish2/subscriptions","organizations_url":"https://api.github.com/users/Smilefish2/orgs","repos_url":"https://api.github.com/users/Smilefish2/repos","events_url":"https://api.github.com/users/Smilefish2/events{/privacy}","received_events_url":"https://api.github.com/users/Smilefish2/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-04-06T10:21:32Z","updated_at":"2018-05-02T03:37:55Z","closed_at":"2018-05-02T03:37:55Z","author_association":"NONE","body":"- Lumen Version: 5.5.*\r\n- PHP Version:7.2.3\r\n- Database Driver & Version: Mysql 5.7\r\n\r\n### Description:\r\n\r\n运行 'php artisan migrate:refresh --seed' 命令时，得到的created_at时间不正确，完整的结果和步骤如下。\r\n\r\n正确时间：2018-04-06 18:16:21\r\n错误时间：2018-04-07 02:13:03\r\n\r\n(×)php artisan migrate:refresh --seed result:\r\n```php\r\nid\tname\t\t\tcreated_at\t\tupdated_at\t\tdeleted_at\r\n1\ttest-DB\t\t\t2018-04-07 02:13:03\t2018-04-07 02:13:03\t\r\n2\ttest-model-create\t2018-04-07 02:13:03\t2018-04-07 02:13:03\t\r\n3\ttest-save\t\t2018-04-07 02:13:03\t2018-04-07 02:13:03\t\r\n4\tAlycia Reilly DVM\t2018-04-07 02:13:03\t2018-04-07 02:13:03\t\t\r\n```\r\n\r\n(√)php artisan migrate:refresh && php artisan db:seed result:\r\n\r\n```php\r\nid\tname\t\t\tcreated_at\t\tupdated_at\t\tdeleted_at\r\n1\ttest-DB\t\t\t2018-04-06 18:16:21\t2018-04-06 18:16:21\t\r\n2\ttest-model-create\t2018-04-06 18:16:21\t2018-04-06 18:16:21\t\r\n3\ttest-save\t\t2018-04-06 18:16:21\t2018-04-06 18:16:21\t\r\n4\tJavon Bradtke\t\t2018-04-06 18:16:21\t2018-04-06 18:16:21\t\t\t\r\n```\r\n\r\n\r\n### Steps To Reproduce:\r\n.env:\r\n\r\n```php\r\nAPP_TIMEZONE=PRC\r\nDB_TIMEZONE=+08:00\r\n```\r\n\r\nmigration:\r\n\r\n```php\r\nSchema::create('test', function (Blueprint $table) {\r\n    $table->bigIncrements('id');\r\n    $table->string('name')->default('');\r\n    $table->timestamps();\r\n    $table->softDeletes();\r\n});\r\n```\r\n\r\nmodel:\r\n\r\n```php\r\nnamespace Common\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model as IlluminateModel;\r\n\r\n/**\r\n * Test\r\n */\r\nclass Test extends IlluminateModel\r\n{\r\n    /**\r\n     * The table associated with the model.\r\n     *\r\n     * @var string\r\n     */\r\n    protected $table = 'test';\r\n\r\n\r\n}\r\n```\r\n\r\nTestSeeder:\r\n\r\n```php\r\nuse Carbon\\Carbon;\r\nuse Common\\Models\\Test;\r\nuse Illuminate\\Database\\Seeder;\r\n\r\nclass TestSeeder extends Seeder\r\n{\r\n    /**\r\n     * Run the database seeds.\r\n     *\r\n     * @return void\r\n     */\r\n    public function run()\r\n    {\r\n        # run command: php artisan db:seed --class=TestSeeder\r\n\r\n        // use DB\r\n        $now = Carbon::now()->toDateTimeString();\r\n        DB::table('test')->insert([\r\n            [\r\n                'name' => 'test-DB',\r\n                'created_at' => $now,\r\n                'updated_at' => $now,\r\n            ],\r\n        ]);\r\n\r\n        // use model create\r\n        Test::create([\r\n            'name' => 'test-model-create'\r\n        ]);\r\n\r\n        // test save\r\n        $test = new Test();\r\n        $test->name = 'test-save';\r\n        $test->save();\r\n\r\n        // test factory\r\n        factory(Common\\Models\\Test::class, 1)->create()->each(function ($t) {\r\n            $t->save();\r\n        });\r\n    }\r\n}\r\n```\r\n\r\nDatabaseSeeder:\r\n```php\r\n     $this->call([\r\n         TestSeeder::class,\r\n     ]);\r\n```\r\n\r\n\r\nCommand:\r\n```php\r\nphp artisan migrate:refresh --seed\r\n\r\nphp artisan migrate:refresh && php artisan db:seed\r\n```\r\n\r\n"}}
{"actor":{"display_login":"Smilefish2"}}