mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
LibraryItemType enum added
This commit is contained in:
50
app/Enums/LibraryItemType.php
Normal file
50
app/Enums/LibraryItemType.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use ArchTech\Enums\From;
|
||||
use ArchTech\Enums\InvokableCases;
|
||||
use ArchTech\Enums\Options;
|
||||
use ArchTech\Enums\Values;
|
||||
|
||||
enum LibraryItemType: string
|
||||
{
|
||||
use InvokableCases;
|
||||
use Values;
|
||||
use Options;
|
||||
use From;
|
||||
|
||||
case Book = 'book';
|
||||
case BlogArticle = 'blog_article';
|
||||
case MarkdownArticle = 'markdown_article';
|
||||
case YoutubeVideo = 'youtube_video';
|
||||
case VimeoVideo = 'vimeo_video';
|
||||
case PodcastEpisode = 'podcast_episode';
|
||||
case DownloadableFile = 'downloadable_file';
|
||||
|
||||
public static function labels(): array
|
||||
{
|
||||
return [
|
||||
'book' => __('Book'),
|
||||
'blog_article' => __('Article'),
|
||||
'markdown_article' => __('Markdown Article'),
|
||||
'youtube_video' => __('Youtube Video'),
|
||||
'vimeo_video' => __('Vimeo Video'),
|
||||
'podcast_episode' => __('Podcast Episode'),
|
||||
'downloadable_file' => __('Downloadable File'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function icons(): array
|
||||
{
|
||||
return [
|
||||
'book' => 'book',
|
||||
'blog_article' => 'newspaper',
|
||||
'markdown_article' => 'newspaper',
|
||||
'youtube_video' => 'video',
|
||||
'vimeo_video' => 'video',
|
||||
'podcast_episode' => 'podcast',
|
||||
'downloadable_file' => 'download',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Livewire\Tables;
|
||||
|
||||
use App\Enums\LibraryItemType;
|
||||
use App\Models\Library;
|
||||
use App\Models\LibraryItem;
|
||||
use App\Models\Tag;
|
||||
@@ -11,6 +12,7 @@ use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
|
||||
use Spatie\LaravelOptions\Options;
|
||||
|
||||
class LibraryItemTable extends DataTableComponent
|
||||
{
|
||||
@@ -78,6 +80,22 @@ class LibraryItemTable extends DataTableComponent
|
||||
fn($query) => $query->where('libraries.name', 'ilike', "%$value%"));
|
||||
}
|
||||
}),
|
||||
SelectFilter::make('Art')
|
||||
->options(
|
||||
collect(
|
||||
Options::forEnum(LibraryItemType::class)
|
||||
->toArray()
|
||||
)
|
||||
->mapWithKeys(fn($value, $key) => [$value['value'] => $value['label']])
|
||||
->prepend('Alle', '')
|
||||
->toArray()
|
||||
)
|
||||
->filter(function (Builder $builder, string $value) {
|
||||
if ($value === 'Alle') {
|
||||
return;
|
||||
}
|
||||
$builder->where('library_items.type', $value);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -102,6 +120,15 @@ class LibraryItemTable extends DataTableComponent
|
||||
Column::make("Name", "name")
|
||||
->sortable(),
|
||||
Column::make("Art", "type")
|
||||
->format(
|
||||
function ($value, $row, Column $column) {
|
||||
return '<span class="inline-flex items-center rounded-full bg-amber-400 px-2.5 py-0.5 text-base font-medium text-gray-900"><i class="mr-2 fa fa-thin fa-'
|
||||
.LibraryItemType::icons()[$value]
|
||||
.'"></i>'
|
||||
.LibraryItemType::labels()[$value]
|
||||
.'</span>';
|
||||
})
|
||||
->html()
|
||||
->sortable(),
|
||||
Column::make("Tags")
|
||||
->label(
|
||||
@@ -117,8 +144,8 @@ class LibraryItemTable extends DataTableComponent
|
||||
public function builder(): Builder
|
||||
{
|
||||
$shouldBePublic = request()
|
||||
->route()
|
||||
->getName() !== 'library.lecturer';
|
||||
->route()
|
||||
->getName() !== 'library.lecturer';
|
||||
|
||||
return LibraryItem::query()
|
||||
->whereHas('libraries', fn($query) => $query->where('libraries.is_public', $shouldBePublic))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use App\Enums\LibraryItemType;
|
||||
use Ebess\AdvancedNovaMediaLibrary\Fields\Files;
|
||||
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -11,6 +12,7 @@ use Laravel\Nova\Fields\Code;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Spatie\LaravelOptions\Options;
|
||||
use Spatie\TagsField\Tags;
|
||||
|
||||
class LibraryItem extends Resource
|
||||
@@ -74,15 +76,7 @@ class LibraryItem extends Resource
|
||||
|
||||
Select::make('Type')
|
||||
->options(
|
||||
[
|
||||
'book' => 'book',
|
||||
'blog_article' => 'blog_article',
|
||||
'markdown_article' => 'markdown_article',
|
||||
'youtube_video' => 'youtube_video',
|
||||
'vimeo_video' => 'vimeo_video',
|
||||
'podcast_episode' => 'podcast_episode',
|
||||
'downloadable_file' => 'downloadable_file',
|
||||
]
|
||||
Options::forEnum(LibraryItemType::class)->toArray()
|
||||
)
|
||||
->rules('required', 'string'),
|
||||
|
||||
@@ -92,7 +86,7 @@ class LibraryItem extends Resource
|
||||
|
||||
BelongsTo::make('Lecturer'),
|
||||
|
||||
BelongsTo::make('Episode'),
|
||||
BelongsTo::make('Episode')->rules(['nullable']),
|
||||
|
||||
BelongsToMany::make('Library', 'libraries', Library::class),
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"akuechler/laravel-geoly": "^1.0",
|
||||
"archtechx/enums": "^0.3.1",
|
||||
"ebess/advanced-nova-media-library": "^4.0",
|
||||
"ezadr/lnurl-php": "^1.0",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
@@ -30,6 +31,7 @@
|
||||
"spatie/laravel-google-fonts": "^1.2",
|
||||
"spatie/laravel-markdown": "^2.2",
|
||||
"spatie/laravel-medialibrary": "^10.0.0",
|
||||
"spatie/laravel-options": "^1.0",
|
||||
"spatie/laravel-ray": "^1.31",
|
||||
"spatie/laravel-sluggable": "^3.4",
|
||||
"spatie/laravel-tags": "^4.3",
|
||||
|
||||
166
composer.lock
generated
166
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9c4898684e578e46bb709340edf618e8",
|
||||
"content-hash": "bdaacd0e3b0592028578169251930b7a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akuechler/laravel-geoly",
|
||||
@@ -64,6 +64,52 @@
|
||||
},
|
||||
"time": "2021-04-20T07:17:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "archtechx/enums",
|
||||
"version": "v0.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/archtechx/enums.git",
|
||||
"reference": "373a86a16e7233a56dd942d422af2cc59a2becb3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/archtechx/enums/zipball/373a86a16e7233a56dd942d422af2cc59a2becb3",
|
||||
"reference": "373a86a16e7233a56dd942d422af2cc59a2becb3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"nunomaduro/larastan": "^1.0|^2.0",
|
||||
"orchestra/testbench": "^6.9|^7.0",
|
||||
"pestphp/pest": "^1.2",
|
||||
"pestphp/pest-plugin-laravel": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ArchTech\\Enums\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Samuel Štancl",
|
||||
"email": "samuel@archte.ch"
|
||||
}
|
||||
],
|
||||
"description": "Helpers for making PHP enums more lovable.",
|
||||
"support": {
|
||||
"issues": "https://github.com/archtechx/enums/issues",
|
||||
"source": "https://github.com/archtechx/enums/tree/v0.3.1"
|
||||
},
|
||||
"time": "2022-08-24T22:27:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bacon/bacon-qr-code",
|
||||
"version": "2.0.7",
|
||||
@@ -6918,6 +6964,78 @@
|
||||
],
|
||||
"time": "2022-12-06T07:29:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-options",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-options.git",
|
||||
"reference": "7631d2bb99b5b4b507293a4d8823c9244b4c18cb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-options/zipball/7631d2bb99b5b4b507293a4d8823c9244b4c18cb",
|
||||
"reference": "7631d2bb99b5b4b507293a4d8823c9244b4c18cb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "^8.81|^9.0",
|
||||
"php": "^8.1",
|
||||
"spatie/laravel-package-tools": "^1.9.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.8",
|
||||
"myclabs/php-enum": "^1.6",
|
||||
"nunomaduro/collision": "^6.0|^5.0",
|
||||
"nunomaduro/larastan": "^2.0.1|^1.0.3",
|
||||
"orchestra/testbench": "^7.0|^v6.24.1",
|
||||
"pestphp/pest": "^v1.21.3",
|
||||
"pestphp/pest-plugin-laravel": "^1.1",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.0",
|
||||
"phpstan/phpstan-phpunit": "^1.0",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"spatie/enum": "^3.13",
|
||||
"spatie/laravel-model-states": "^2.0",
|
||||
"spatie/laravel-ray": "^1.26"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Spatie\\LaravelOptions\\OptionsServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\LaravelOptions\\": "src",
|
||||
"Spatie\\LaravelOptions\\Database\\Factories\\": "database/factories"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ruben Van Assche",
|
||||
"email": "ruben@spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Create arrays of options from different sources",
|
||||
"homepage": "https://github.com/spatie/laravel-options",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"options",
|
||||
"spatie"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/spatie/laravel-options/tree/1.0.3"
|
||||
},
|
||||
"time": "2022-07-29T08:14:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-package-tools",
|
||||
"version": "1.13.7",
|
||||
@@ -11373,52 +11491,6 @@
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "archtechx/enums",
|
||||
"version": "v0.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/archtechx/enums.git",
|
||||
"reference": "373a86a16e7233a56dd942d422af2cc59a2becb3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/archtechx/enums/zipball/373a86a16e7233a56dd942d422af2cc59a2becb3",
|
||||
"reference": "373a86a16e7233a56dd942d422af2cc59a2becb3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"nunomaduro/larastan": "^1.0|^2.0",
|
||||
"orchestra/testbench": "^6.9|^7.0",
|
||||
"pestphp/pest": "^1.2",
|
||||
"pestphp/pest-plugin-laravel": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ArchTech\\Enums\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Samuel Štancl",
|
||||
"email": "samuel@archte.ch"
|
||||
}
|
||||
],
|
||||
"description": "Helpers for making PHP enums more lovable.",
|
||||
"support": {
|
||||
"issues": "https://github.com/archtechx/enums/issues",
|
||||
"source": "https://github.com/archtechx/enums/tree/v0.3.1"
|
||||
},
|
||||
"time": "2022-08-24T22:27:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/semver",
|
||||
"version": "3.3.2",
|
||||
|
||||
13
config/options.php
Normal file
13
config/options.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
* The key used in an option to describe the label of the option
|
||||
*/
|
||||
'label_key' => 'label',
|
||||
|
||||
/*
|
||||
* The key used in an option to describe the value of the option
|
||||
*/
|
||||
'value_key' => 'value',
|
||||
];
|
||||
@@ -1,4 +1,11 @@
|
||||
{
|
||||
"Book": "Buch",
|
||||
"Article": "Artikel",
|
||||
"Markdown Article": "Interner Artikel",
|
||||
"Youtube Video": "Youtube Video",
|
||||
"Vimeo Video": "Vimeo Video",
|
||||
"Podcast Episode": "Podcast",
|
||||
"Downloadable File": "Download",
|
||||
"Done": "Fertig",
|
||||
"Registration": "Anmeldung",
|
||||
"Lecturer": "Dozent",
|
||||
|
||||
@@ -12,6 +12,8 @@ module.exports = {
|
||||
'./storage/framework/views/*.php',
|
||||
'./resources/views/**/*.blade.php',
|
||||
|
||||
'./app/Http/Livewire/**/*.php',
|
||||
|
||||
'./vendor/rappasoft/laravel-livewire-tables/resources/views/**/*.blade.php',
|
||||
|
||||
'./vendor/wireui/wireui/resources/**/*.blade.php',
|
||||
|
||||
Reference in New Issue
Block a user