- 数据迁移请查看 https://jsjxsz.cn/316.html
- 创建数据填充文件:
php artisan make:seeder FriendsHashMobileSeeder
- 编写代码
<?php
use Illuminate\Database\Seeder;
class FriendsHashMobileSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$friends_invitations = \App\Models\Api\FriendsInvitationsModel::query()
->where('status','pending')
->get();
if (!empty($friends_invitations)){
$friends_invitations = $friends_invitations->toArray();
foreach ($friends_invitations as $k => $v){
\Illuminate\Support\Facades\DB::table('friends')->insert([
'sender_id' => $v['sender_id'],
'hash_mobile' => $v['hash_mobile'],
'status' => 'pending',
'created_at' => $v['created_at']
]);
}
}
}
}
- 执行迁移命令
php artisan db:seed --class FriendsHashMobileSeeder
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END