mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
md5 media file names
This commit is contained in:
45
app/Console/Commands/Database/RenameFileToMd5.php
Normal file
45
app/Console/Commands/Database/RenameFileToMd5.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\Database;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
|
|
||||||
|
class RenameFileToMd5 extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'files:md5';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$media = Media::query()
|
||||||
|
->where('file_name', 'ilike', '%ö%')
|
||||||
|
->orWhere('file_name', 'ilike', '%ä%')
|
||||||
|
->orWhere('file_name', 'ilike', '%ü%')
|
||||||
|
->orWhere('file_name', 'ilike', '%ß%')
|
||||||
|
->get();
|
||||||
|
foreach ($media as $item) {
|
||||||
|
$md5FileName = md5($item->file_name).'.'.$item->extension;
|
||||||
|
$item->file_name = $md5FileName;
|
||||||
|
Storage::disk('public')
|
||||||
|
->move($item->getPath(), dirname($item->getPath()).'/'.$md5FileName);
|
||||||
|
$item->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,6 +41,7 @@ class CommentBookCase extends Component
|
|||||||
|
|
||||||
$this->bookCase
|
$this->bookCase
|
||||||
->addMedia($this->photo)
|
->addMedia($this->photo)
|
||||||
|
->usingFileName(md5($this->photo->getClientOriginalName()) . '.' . $this->photo->getClientOriginalExtension())
|
||||||
->toMediaCollection('images');
|
->toMediaCollection('images');
|
||||||
|
|
||||||
return to_route('bookCases.comment.bookcase', ['country' => $this->country, 'bookCase' => $this->bookCase->id]);
|
return to_route('bookCases.comment.bookcase', ['country' => $this->country, 'bookCase' => $this->bookCase->id]);
|
||||||
|
|||||||
@@ -151,10 +151,12 @@ class BookCaseTable extends DataTableComponent
|
|||||||
$orangePill
|
$orangePill
|
||||||
->addMedia($this->photo)
|
->addMedia($this->photo)
|
||||||
->preservingOriginal()
|
->preservingOriginal()
|
||||||
|
->usingFileName(md5($this->photo->getClientOriginalName()).'.'.$this->photo->getClientOriginalExtension())
|
||||||
->toMediaCollection('images');
|
->toMediaCollection('images');
|
||||||
$orangePill->load(['media']);
|
$orangePill->load(['media']);
|
||||||
$this->currentModal
|
$this->currentModal
|
||||||
->addMedia($this->photo)
|
->addMedia($this->photo)
|
||||||
|
->usingFileName(md5($this->photo->getClientOriginalName()).'.'.$this->photo->getClientOriginalExtension())
|
||||||
->toMediaCollection('images');
|
->toMediaCollection('images');
|
||||||
if ($this->orangepill['comment']) {
|
if ($this->orangepill['comment']) {
|
||||||
$this->currentModal->comment($this->orangepill['comment'], null);
|
$this->currentModal->comment($this->orangepill['comment'], null);
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ class BitcoinEvent extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
|
|
||||||
Images::make(__('Logo'), 'logo')
|
Images::make(__('Logo'), 'logo')
|
||||||
->conversionOnIndexView('thumb'),
|
->showStatistics()
|
||||||
|
->conversionOnIndexView('thumb')
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Boolean::make(__('Show worldwide'), 'show_worldwide')
|
Boolean::make(__('Show worldwide'), 'show_worldwide')
|
||||||
->help(__('If checked, the event will be shown everywhere.')),
|
->help(__('If checked, the event will be shown everywhere.')),
|
||||||
@@ -92,14 +94,17 @@ class BitcoinEvent extends Resource
|
|||||||
->rules('required', 'string'),
|
->rules('required', 'string'),
|
||||||
|
|
||||||
BelongsTo::make(__('Venue'), 'venue', Venue::class)
|
BelongsTo::make(__('Venue'), 'venue', Venue::class)
|
||||||
->searchable()->showCreateRelationButton()->withSubtitles(),
|
->searchable()
|
||||||
|
->showCreateRelationButton()
|
||||||
|
->withSubtitles(),
|
||||||
|
|
||||||
BelongsTo::make(__('Created By'), 'createdBy', User::class)
|
BelongsTo::make(__('Created By'), 'createdBy', User::class)
|
||||||
->canSee(function ($request) {
|
->canSee(function ($request) {
|
||||||
return $request->user()
|
return $request->user()
|
||||||
->hasRole('super-admin');
|
->hasRole('super-admin');
|
||||||
})
|
})
|
||||||
->searchable()->withSubtitles(),
|
->searchable()
|
||||||
|
->withSubtitles(),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,12 +85,16 @@ class Course extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
|
|
||||||
Images::make(__('Main picture'), 'logo')
|
Images::make(__('Main picture'), 'logo')
|
||||||
->conversionOnIndexView('thumb'),
|
->showStatistics()
|
||||||
|
->conversionOnIndexView('thumb')
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
// todo: english
|
// todo: english
|
||||||
Images::make(__('Images'), 'images')
|
Images::make(__('Images'), 'images')
|
||||||
|
->showStatistics()
|
||||||
->conversionOnIndexView('thumb')
|
->conversionOnIndexView('thumb')
|
||||||
->help(__('Upload images here to insert them later in the Markdown Description. But you have to save before.')),
|
->help(__('Upload images here to insert them later in the Markdown Description. But you have to save before.'))
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Tags::make(__('Tags'))
|
Tags::make(__('Tags'))
|
||||||
->type('course')
|
->type('course')
|
||||||
|
|||||||
@@ -79,11 +79,15 @@ class Lecturer extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
|
|
||||||
Images::make('Avatar', 'avatar')
|
Images::make('Avatar', 'avatar')
|
||||||
->conversionOnIndexView('thumb'),
|
->showStatistics()
|
||||||
|
->conversionOnIndexView('thumb')
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Images::make(__('Images'), 'images')
|
Images::make(__('Images'), 'images')
|
||||||
|
->showStatistics()
|
||||||
->conversionOnIndexView('thumb')
|
->conversionOnIndexView('thumb')
|
||||||
->help('Upload images here to insert them later in the Markdown Description. But you have to save before.'),
|
->help('Upload images here to insert them later in the Markdown Description. But you have to save before.')
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Text::make('Name')
|
Text::make('Name')
|
||||||
->rules('required', 'string'),
|
->rules('required', 'string'),
|
||||||
|
|||||||
@@ -105,16 +105,20 @@ class LibraryItem extends Resource
|
|||||||
|
|
||||||
Images::make(__('Main picture'), 'main')
|
Images::make(__('Main picture'), 'main')
|
||||||
->conversionOnIndexView('thumb')
|
->conversionOnIndexView('thumb')
|
||||||
->showStatistics(),
|
->showStatistics()
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Images::make(__('Images'), 'images')
|
Images::make(__('Images'), 'images')
|
||||||
->conversionOnIndexView('thumb')
|
->conversionOnIndexView('thumb')
|
||||||
->help('Upload images here to insert them later in the Markdown Description. But you have to save before.')
|
->help('Upload images here to insert them later in the Markdown Description. But you have to save before.')
|
||||||
->hideFromIndex()
|
->hideFromIndex()
|
||||||
->showStatistics(),
|
->showStatistics()
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Files::make(__('Downloadable File'), 'single_file')
|
Files::make(__('Downloadable File'), 'single_file')
|
||||||
->help(__('Please contact the admins for new file types, otherwise pack the files in a ZIP! (Currently: PDF, ZIP)')),
|
->showStatistics()
|
||||||
|
->help(__('Please contact the admins for new file types, otherwise pack the files in a ZIP! (Currently: PDF, ZIP)'))
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Select::make(__('Language Code'), 'language_code')
|
Select::make(__('Language Code'), 'language_code')
|
||||||
->options(
|
->options(
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ class Meetup extends Resource
|
|||||||
|
|
||||||
Images::make(__('Logo'), 'logo')
|
Images::make(__('Logo'), 'logo')
|
||||||
->conversionOnIndexView('thumb')
|
->conversionOnIndexView('thumb')
|
||||||
->showStatistics(),
|
->showStatistics()
|
||||||
|
->setFileName(fn($originalFilename, $extension, $model) => md5($originalFilename).'.'.$extension),
|
||||||
|
|
||||||
Text::make('Name')
|
Text::make('Name')
|
||||||
->rules('required', 'string')
|
->rules('required', 'string')
|
||||||
|
|||||||
Reference in New Issue
Block a user