mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
Apply Laravel coding style
Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions. You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root. For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
This commit is contained in:
committed by
HolgerHatGarKeineNode
parent
a15ca4a2bc
commit
5776b01d15
@@ -19,53 +19,58 @@ class LibraryItemForm extends Component
|
||||
public Country $country;
|
||||
|
||||
public ?LibraryItem $libraryItem = null;
|
||||
|
||||
public $library;
|
||||
|
||||
public $image;
|
||||
|
||||
public $file;
|
||||
|
||||
public array $selectedTags = [];
|
||||
|
||||
public bool $lecturer = false;
|
||||
|
||||
public ?string $fromUrl = '';
|
||||
|
||||
protected $queryString = [
|
||||
'fromUrl' => ['except' => ''],
|
||||
'fromUrl' => ['except' => ''],
|
||||
'lecturer' => ['except' => false],
|
||||
];
|
||||
|
||||
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'],
|
||||
|
||||
'library' => 'required',
|
||||
|
||||
'selectedTags' => 'array|min:1',
|
||||
|
||||
'libraryItem.lecturer_id' => 'required',
|
||||
'libraryItem.name' => 'required',
|
||||
'libraryItem.type' => 'required',
|
||||
'libraryItem.language_code' => 'required',
|
||||
'libraryItem.value' => [
|
||||
'libraryItem.lecturer_id' => 'required',
|
||||
'libraryItem.name' => 'required',
|
||||
'libraryItem.type' => 'required',
|
||||
'libraryItem.language_code' => 'required',
|
||||
'libraryItem.value' => [
|
||||
'required',
|
||||
Rule::when(
|
||||
$this->libraryItem->type !== LibraryItemType::MarkdownArticle
|
||||
&& $this->libraryItem->type !== LibraryItemType::MarkdownArticleExtern
|
||||
&& $this->libraryItem->type !== LibraryItemType::DownloadableFile, ['url']
|
||||
)
|
||||
),
|
||||
],
|
||||
'libraryItem.subtitle' => 'required',
|
||||
'libraryItem.excerpt' => 'required',
|
||||
'libraryItem.subtitle' => 'required',
|
||||
'libraryItem.excerpt' => 'required',
|
||||
'libraryItem.main_image_caption' => 'required',
|
||||
'libraryItem.read_time' => 'required',
|
||||
'libraryItem.approved' => 'boolean',
|
||||
'libraryItem.read_time' => 'required',
|
||||
'libraryItem.approved' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
if (!$this->libraryItem) {
|
||||
if (! $this->libraryItem) {
|
||||
$this->libraryItem = new LibraryItem([
|
||||
'approved' => true,
|
||||
'approved' => true,
|
||||
'read_time' => 1,
|
||||
]);
|
||||
if ($this->lecturer) {
|
||||
@@ -76,13 +81,13 @@ class LibraryItemForm extends Component
|
||||
$this->selectedTags = $this->libraryItem->tags()
|
||||
->where('type', 'library_item')
|
||||
->get()
|
||||
->map(fn($tag) => $tag->name)
|
||||
->map(fn ($tag) => $tag->name)
|
||||
->toArray();
|
||||
$this->library = $this->libraryItem->libraries()
|
||||
->first()
|
||||
->id;
|
||||
}
|
||||
if (!$this->fromUrl) {
|
||||
if (! $this->fromUrl) {
|
||||
$this->fromUrl = url()->previous();
|
||||
}
|
||||
}
|
||||
@@ -118,7 +123,7 @@ class LibraryItemForm extends Component
|
||||
{
|
||||
$selectedTags = collect($this->selectedTags);
|
||||
if ($selectedTags->contains($name)) {
|
||||
$selectedTags = $selectedTags->filter(fn($tag) => $tag !== $name);
|
||||
$selectedTags = $selectedTags->filter(fn ($tag) => $tag !== $name);
|
||||
} else {
|
||||
$selectedTags->push($name);
|
||||
}
|
||||
@@ -129,21 +134,21 @@ class LibraryItemForm extends Component
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.library.form.library-item-form', [
|
||||
'types' => Options::forEnum(LibraryItemType::class)
|
||||
'types' => Options::forEnum(LibraryItemType::class)
|
||||
->filter(
|
||||
fn($type) => $type !== LibraryItemType::PodcastEpisode
|
||||
fn ($type) => $type !== LibraryItemType::PodcastEpisode
|
||||
&& $type !== LibraryItemType::MarkdownArticle
|
||||
)
|
||||
->toArray(),
|
||||
'libraries' => Library::query()
|
||||
->where('is_public', true)
|
||||
->get()
|
||||
->map(fn($library) => [
|
||||
'id' => $library->id,
|
||||
->map(fn ($library) => [
|
||||
'id' => $library->id,
|
||||
'name' => $library->name,
|
||||
])
|
||||
->toArray(),
|
||||
'tags' => Tag::query()
|
||||
'tags' => Tag::query()
|
||||
->where('type', 'library_item')
|
||||
->get(),
|
||||
]);
|
||||
|
||||
@@ -12,7 +12,9 @@ use RalphJSmit\Laravel\SEO\Support\SEOData;
|
||||
class LibraryTable extends Component
|
||||
{
|
||||
public Country $country;
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public bool $isLecturerPage = false;
|
||||
|
||||
public string $search = '';
|
||||
@@ -23,8 +25,8 @@ class LibraryTable extends Component
|
||||
|
||||
protected $queryString = [
|
||||
'currentTab' => ['except' => '*'],
|
||||
'filters' => ['except' => ''],
|
||||
'search' => ['except' => ''],
|
||||
'filters' => ['except' => ''],
|
||||
'search' => ['except' => ''],
|
||||
];
|
||||
|
||||
public function loadMore()
|
||||
@@ -52,7 +54,7 @@ class LibraryTable extends Component
|
||||
|
||||
public function render()
|
||||
{
|
||||
$shouldBePublic = !$this->isLecturerPage;
|
||||
$shouldBePublic = ! $this->isLecturerPage;
|
||||
$libraries = \App\Models\Library::query()
|
||||
->whereNull('parent_id')
|
||||
->where('is_public', $shouldBePublic)
|
||||
@@ -61,7 +63,7 @@ class LibraryTable extends Component
|
||||
$tabs = collect([
|
||||
[
|
||||
'name' => '*',
|
||||
]
|
||||
],
|
||||
]);
|
||||
foreach ($libraries as $library) {
|
||||
$tabs->push([
|
||||
@@ -82,32 +84,32 @@ class LibraryTable extends Component
|
||||
}
|
||||
|
||||
return view('livewire.library.library-table', [
|
||||
'libraries' => $tabs,
|
||||
'libraries' => $tabs,
|
||||
'libraryItems' => LibraryItem::query()
|
||||
->with([
|
||||
'lecturer',
|
||||
'tags',
|
||||
])
|
||||
->when($this->search, fn($query) => $query
|
||||
->when($this->search, fn ($query) => $query
|
||||
->where('name', 'ilike', '%'.$this->search.'%')
|
||||
->orWhere(fn($query) => $query
|
||||
->orWhere(fn ($query) => $query
|
||||
->when(count($searchTags) > 0 && count($this->filters) < 1,
|
||||
fn($query) => $query->whereHas('tags',
|
||||
fn($query) => $query->whereIn('tags.id', $searchTags)))
|
||||
fn ($query) => $query->whereHas('tags',
|
||||
fn ($query) => $query->whereIn('tags.id', $searchTags)))
|
||||
)
|
||||
)
|
||||
->when($this->currentTab !== '*', fn($query) => $query
|
||||
->when($this->currentTab !== '*', fn ($query) => $query
|
||||
->whereHas('libraries',
|
||||
fn($query) => $query
|
||||
fn ($query) => $query
|
||||
->where('libraries.name', $this->currentTab)
|
||||
)
|
||||
)
|
||||
->when(isset($this->filters['tag']), fn($query) => $query->whereHas('tags',
|
||||
fn($query) => $query->whereIn('tags.id', $this->filters['tag'])))
|
||||
->when(isset($this->filters['tag']), fn ($query) => $query->whereHas('tags',
|
||||
fn ($query) => $query->whereIn('tags.id', $this->filters['tag'])))
|
||||
->when(isset($this->filters['language']),
|
||||
fn($query) => $query->whereIn('language_code', $this->filters['language']))
|
||||
fn ($query) => $query->whereIn('language_code', $this->filters['language']))
|
||||
->whereHas('libraries',
|
||||
fn($query) => $query->where('libraries.is_public', $shouldBePublic))
|
||||
fn ($query) => $query->where('libraries.is_public', $shouldBePublic))
|
||||
->orderByDesc('library_items.created_at')
|
||||
->paginate($this->perPage),
|
||||
])->layout('layouts.app', [
|
||||
@@ -115,7 +117,7 @@ class LibraryTable extends Component
|
||||
title: __('Library'),
|
||||
description: __('Here you can find all content that are available in the library.'),
|
||||
image: asset('img/screenshot.png')
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Livewire\Component;
|
||||
class SearchByTagComponent extends Component
|
||||
{
|
||||
public string $country = 'de';
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
protected $queryString = [
|
||||
@@ -26,12 +27,12 @@ class SearchByTagComponent extends Component
|
||||
->pluck('language_code')
|
||||
->unique()
|
||||
->sort()
|
||||
->map(fn($item) => str($item)
|
||||
->map(fn ($item) => str($item)
|
||||
->before('_')
|
||||
->toString())
|
||||
->values()
|
||||
->toArray(),
|
||||
'tags' => Tag::query()
|
||||
'tags' => Tag::query()
|
||||
->with([
|
||||
'libraryItems.libraries',
|
||||
'libraryItems.lecturer',
|
||||
@@ -41,7 +42,7 @@ class SearchByTagComponent extends Component
|
||||
])
|
||||
->where('type', 'library_item')
|
||||
->whereHas('libraryItems.libraries',
|
||||
fn($query) => $query->where('is_public', $shouldBePublic))
|
||||
fn ($query) => $query->where('is_public', $shouldBePublic))
|
||||
->orderByDesc('library_items_count')
|
||||
->orderBy('tags.id')
|
||||
->get(),
|
||||
|
||||
Reference in New Issue
Block a user