Skip to content

Commit

Permalink
fix a bad album
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Miller committed Oct 24, 2019
1 parent 545f9dc commit c46f827
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions app/Console/Commands/ReIndexAlbum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace App\Console\Commands;

use Google_Client;
use App\Models\Album;
use App\Models\Photo;
use Illuminate\Console\Command;
use Google_Service_PhotosLibrary;
use Illuminate\Support\Facades\Storage;

class ReIndexAlbum extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'photos:reindex {albumId}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Destroy and re-index a troublesome album';
protected $photoservice;
protected $storage;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct(Google_Client $gclient)
{
parent::__construct();
$this->photoservice = new Google_Service_PhotosLibrary($gclient);
$this->storage = Storage::disk('photos');
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$albumId = $this->argument('albumId');
Album::where('id','=',$albumId)->delete();
Photo::where('album_id','=',$albumId)->delete();
if($this->storage->has($albumId)) {
$this->storage->deleteDirectory($albumId);
}
$this->call('photos:index');
}
}

0 comments on commit c46f827

Please sign in to comment.