mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
extract logos
This commit is contained in:
44
app/Console/Commands/Database/ExtractLogos.php
Normal file
44
app/Console/Commands/Database/ExtractLogos.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\Database;
|
||||||
|
|
||||||
|
use App\Models\Meetup;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class ExtractLogos extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'logos';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$meetups = Meetup::query()
|
||||||
|
->with([
|
||||||
|
'media',
|
||||||
|
])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($meetups as $meetup) {
|
||||||
|
$logo = $meetup->getFirstMedia('logo');
|
||||||
|
if ($logo) {
|
||||||
|
if (file_exists($logo->getPath())) {
|
||||||
|
Storage::disk('public')
|
||||||
|
->put('00_logos/'.$meetup->name.'.'.$logo->extension, file_get_contents($logo->getPath()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user