12345678910111213141516171819202122232425 |
- <?php
- use app\common\model\Comment;
- use think\facade\Db;
- use think\migration\Seeder;
- class UpdateCommentNickName extends Seeder
- {
- /**
- * Run Method.
- *
- * Write your database seeder using this method.
- *
- * More information on writing seeders is available here:
- * http://docs.phinx.org/en/latest/seeding.html
- */
- public function run()
- {
- $comments = Comment::with(['user'])->select();
- foreach($comments as $item) {
- $item->nick_name = $item->user->nick_name ?? '';
- $item->save();
- }
- }
- }
|