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:
Shift
2023-02-19 16:18:46 +00:00
committed by HolgerHatGarKeineNode
parent a15ca4a2bc
commit 5776b01d15
333 changed files with 4915 additions and 4967 deletions

View File

@@ -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(),
]);