mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-13 06:56:48 +00:00
normalize filenames
This commit is contained in:
@@ -47,7 +47,7 @@ class BitcoinEventForm extends Component
|
||||
if (!$this->bitcoinEvent) {
|
||||
$this->bitcoinEvent = new BitcoinEvent(
|
||||
[
|
||||
'description' => '',
|
||||
'description' => '',
|
||||
'show_worldwide' => true,
|
||||
]
|
||||
);
|
||||
@@ -76,6 +76,7 @@ class BitcoinEventForm extends Component
|
||||
|
||||
if ($this->image) {
|
||||
$this->bitcoinEvent->addMedia($this->image)
|
||||
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
|
||||
->toMediaCollection('logo');
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ class OrangePillForm extends Component
|
||||
} elseif ($this->orangePill->user_id !== auth()->id()) {
|
||||
abort(403);
|
||||
}
|
||||
if (!$this->fromUrl) {
|
||||
$this->fromUrl = url()->previous();
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
|
||||
@@ -62,10 +62,11 @@ class ContentCreatorForm extends Component
|
||||
|
||||
if ($this->image) {
|
||||
$this->lecturer->addMedia($this->image)
|
||||
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
|
||||
->toMediaCollection('avatar');
|
||||
}
|
||||
|
||||
return redirect($this->fromUrl ?? url()->route('welcome'));
|
||||
return redirect($this->fromUrl);
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -72,7 +72,7 @@ class LibraryItemForm extends Component
|
||||
$this->libraryItem = new LibraryItem([
|
||||
'approved' => true,
|
||||
'read_time' => 1,
|
||||
'value' => '',
|
||||
'value' => '',
|
||||
]);
|
||||
if ($this->lecturer) {
|
||||
$this->library = Library::query()
|
||||
@@ -106,11 +106,13 @@ class LibraryItemForm extends Component
|
||||
|
||||
if ($this->image) {
|
||||
$this->libraryItem->addMedia($this->image)
|
||||
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
|
||||
->toMediaCollection('main');
|
||||
}
|
||||
|
||||
if ($this->file) {
|
||||
$this->libraryItem->addMedia($this->file)
|
||||
->usingFileName(md5($this->file->getClientOriginalName()).'.'.$this->file->getClientOriginalExtension())
|
||||
->toMediaCollection('single_file');
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ class MeetupEventForm extends Component
|
||||
|
||||
public array $series = [];
|
||||
|
||||
public ?string $fromUrl = '';
|
||||
|
||||
protected $queryString = ['fromUrl' => ['except' => '']];
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
@@ -52,6 +56,9 @@ class MeetupEventForm extends Component
|
||||
->can('update', $this->meetupEvent)) {
|
||||
abort(403);
|
||||
}
|
||||
if (!$this->fromUrl) {
|
||||
$this->fromUrl = url()->previous();
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedMeetupEventStart($value)
|
||||
|
||||
@@ -57,6 +57,9 @@ class MeetupForm extends Component
|
||||
) {
|
||||
abort(403);
|
||||
}
|
||||
if (!$this->fromUrl) {
|
||||
$this->fromUrl = url()->previous();
|
||||
}
|
||||
}
|
||||
|
||||
public function submit()
|
||||
@@ -66,6 +69,7 @@ class MeetupForm extends Component
|
||||
|
||||
if ($this->image) {
|
||||
$this->meetup->addMedia($this->image)
|
||||
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
|
||||
->toMediaCollection('logo');
|
||||
}
|
||||
|
||||
|
||||
@@ -23,22 +23,26 @@ class NewsArticleForm extends Component
|
||||
|
||||
public array $temporaryUrls = [];
|
||||
|
||||
public ?string $fromUrl = '';
|
||||
|
||||
protected $queryString = ['fromUrl' => ['except' => '']];
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'image' => [Rule::requiredIf(! $this->libraryItem->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'],
|
||||
'image' => [Rule::requiredIf(!$this->libraryItem->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'],
|
||||
|
||||
'libraryItem.lecturer_id' => 'required',
|
||||
'libraryItem.name' => 'required',
|
||||
'libraryItem.type' => 'required',
|
||||
'libraryItem.language_code' => 'required',
|
||||
'libraryItem.value' => 'required',
|
||||
'libraryItem.subtitle' => 'required',
|
||||
'libraryItem.excerpt' => 'required',
|
||||
'libraryItem.lecturer_id' => 'required',
|
||||
'libraryItem.name' => 'required',
|
||||
'libraryItem.type' => 'required',
|
||||
'libraryItem.language_code' => 'required',
|
||||
'libraryItem.value' => 'required',
|
||||
'libraryItem.subtitle' => 'required',
|
||||
'libraryItem.excerpt' => 'required',
|
||||
'libraryItem.main_image_caption' => 'required',
|
||||
'libraryItem.read_time' => 'required',
|
||||
'libraryItem.approved' => 'boolean',
|
||||
'libraryItem.news' => 'boolean',
|
||||
'libraryItem.read_time' => 'required',
|
||||
'libraryItem.approved' => 'boolean',
|
||||
'libraryItem.news' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -46,16 +50,19 @@ class NewsArticleForm extends Component
|
||||
{
|
||||
if ($this->libraryItem === null) {
|
||||
$this->libraryItem = new LibraryItem([
|
||||
'type' => 'markdown_article',
|
||||
'value' => '',
|
||||
'read_time' => 1,
|
||||
'news' => true,
|
||||
'type' => 'markdown_article',
|
||||
'value' => '',
|
||||
'read_time' => 1,
|
||||
'news' => true,
|
||||
'language_code' => 'de',
|
||||
'approved' => auth()
|
||||
'approved' => auth()
|
||||
->user()
|
||||
->hasRole('news-editor'),
|
||||
]);
|
||||
}
|
||||
if (!$this->fromUrl) {
|
||||
$this->fromUrl = url()->previous();
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedImages($value)
|
||||
@@ -76,17 +83,18 @@ class NewsArticleForm extends Component
|
||||
|
||||
if ($this->image) {
|
||||
$this->libraryItem->addMedia($this->image)
|
||||
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
|
||||
->toMediaCollection('main');
|
||||
}
|
||||
|
||||
return to_route('article.overview', ['country' => null]);
|
||||
return redirect($this->fromUrl);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->libraryItem->delete();
|
||||
|
||||
return to_route('article.overview', ['country' => null]);
|
||||
return redirect($this->fromUrl);
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -74,6 +74,7 @@ class VenueForm extends Component
|
||||
if ($this->images && count($this->images) > 0) {
|
||||
foreach ($this->images as $item) {
|
||||
$this->venue->addMedia($item)
|
||||
->usingFileName(md5($item->getClientOriginalName()).'.'.$item->getClientOriginalExtension())
|
||||
->toMediaCollection('images');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user