More Laravel/AdminLTE updates

This commit is contained in:
Deon George
2019-11-23 12:51:30 +11:00
parent 6a17fd3716
commit bafc34b1c0
26 changed files with 410 additions and 565 deletions

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Jobs\PhotoDelete;
use App\Models\Photo;
class PhotoAutoDelete extends Command
{
use DispatchesJobs;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'photo:autodelete';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Auto Delete Photos';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Photo::where('remove',1)->chunk(10,function($chunk) {
foreach ($chunk as $o) {
foreach ($o->list_duplicates(TRUE) as $oo) {
if (! $oo->signature OR ! $oo->file_signature)
continue;
if ($oo->signature == $o->signature AND $oo->file_signature == $o->file_signature) {
if ($oo->remove) {
$this->info(sprintf('Removing: %s (%s)',$oo->id,$oo->filename));
$this->dispatch((new PhotoDelete($o))->onQueue('delete'));
}
}
}
}
});
}
}