Skip to content

Commit ca68911

Browse files
add comand to migrate the logos for each organization
1 parent ecceb4c commit ca68911

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Console\Commands;
6+
7+
use App\Models\Organisation;
8+
use Illuminate\Console\Command;
9+
10+
class MoveOrganisationLogoToPublicBucket extends Command
11+
{
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'app:move-organisation-logo-to-public-bucket';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Move organisation logo to public bucket';
25+
26+
/**
27+
* Execute the console command.
28+
*/
29+
public function handle()
30+
{
31+
Organisation::query()
32+
->whereHas('media')
33+
->each(function (Organisation $organisation) {
34+
$logo = $organisation->getFirstMedia('default');
35+
$logo->move($organisation, 'default', 's3-public');
36+
$this->info("Moved logo for organisation: {$organisation->name}");
37+
});
38+
}
39+
}

0 commit comments

Comments
 (0)