| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Storage;
- class SyncOss extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'sync:oss';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '图片同步到腾讯云OSS';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- // 同步头像
- // $this->syncAvatar();
- // $this->syncAttires();
- // $this->syncGift();
- // $this->syncPack();
- // $this->syncLiveRoom();
- // $this->syncResource();
- return 0;
- }
- public function syncAvatar() {
- $avatars = \App\Models\Account::all();
- $avatars->each(function ($item, $key) {
- $v = Storage::disk("cosv5")->put($item->avatar, Storage::disk('admin')->get($item->avatar));
- if(!$v) {
- dump("出错了".$item->avatar);
- } else {
- dump("ok".$item->avatar);
- }
- });
- }
- public function syncAttires() {
- $avatars = \App\Models\Attire::all();
- $avatars->each(function ($item, $key) {
- $v = Storage::disk("cosv5")->put($item->img_1, Storage::disk('admin')->get($item->img_1));
- if(!$v) {
- dump("出错了".$item->img_1);
- } else {
- dump("ok".$item->img_1);
- }
- $v = Storage::disk("cosv5")->put($item->img_2, Storage::disk('admin')->get($item->img_2));
- if(!$v) {
- dump("出错了".$item->img_2);
- } else {
- dump("ok".$item->img_2);
- }
- });
- }
- public function syncGift() {
- $avatars = \App\Models\Gift::all();
- $avatars->each(function ($item, $key) {
- $v = Storage::disk("cosv5")->put($item->img, Storage::disk('admin')->get($item->img));
- if(!$v) {
- dump("出错了".$item->img);
- } else {
- dump("ok".$item->img);
- }
- });
- }
- public function syncPack() {
- $avatars = \App\Models\GiftPack::all();
- $avatars->each(function ($item, $key) {
- $v = Storage::disk("cosv5")->put($item->img, Storage::disk('admin')->get($item->img));
- if(!$v) {
- dump("出错了-".$item->img);
- } else {
- dump("ok-".$item->img);
- }
- });
- }
- public function syncLiveRoom() {
- $avatars = \App\Models\LiveRoom::all();
- $avatars->each(function ($item, $key) {
- $v = Storage::disk("cosv5")->put($item->img, Storage::disk('admin')->get($item->img));
- if(!$v) {
- dump("出错了-".$item->img);
- } else {
- dump("ok-".$item->img);
- }
- });
- }
- public function syncResource() {
- $avatars = \App\Models\Resource::all();
- $avatars->each(function ($item, $key) {
- $v = Storage::disk("cosv5")->put($item->src, Storage::disk('admin')->get($item->src));
- if(!$v) {
- dump("出错了-".$item->src);
- } else {
- dump("ok-".$item->src);
- }
- });
- }
- }
|