diff --git a/app/Nova/Podcast.php b/app/Nova/Podcast.php index 8ae8875b..95548f2f 100644 --- a/app/Nova/Podcast.php +++ b/app/Nova/Podcast.php @@ -3,7 +3,9 @@ namespace App\Nova; use Illuminate\Http\Request; +use Illuminate\Support\Str; use Laravel\Nova\Fields\Avatar; +use Laravel\Nova\Fields\Boolean; use Laravel\Nova\Fields\Code; use Laravel\Nova\Fields\HasMany; use Laravel\Nova\Fields\ID; @@ -41,6 +43,8 @@ class Podcast extends Resource */ public function fields(Request $request) { + $guid = $this->guid ?? Str::uuid(); + return [ ID::make() ->sortable(), @@ -48,8 +52,19 @@ class Podcast extends Resource Avatar::make('Image') ->squared() ->thumbnail(function () { - return $this->data['image']; - }), + return $this?->data['image'] ?? ''; + }) + ->exceptOnForms(), + + Boolean::make('Locked', 'locked', fn($value) => $value ?? false), + + Text::make('Guid', 'guid', function ($value) use ($guid) { + if ($value) { + return $value; + } else { + return $guid; + } + }), Text::make('Title') ->rules('required', 'string'), diff --git a/app/Policies/PodcastPolicy.php b/app/Policies/PodcastPolicy.php index cbe691b7..5d553097 100644 --- a/app/Policies/PodcastPolicy.php +++ b/app/Policies/PodcastPolicy.php @@ -41,7 +41,7 @@ class PodcastPolicy */ public function create(User $user) { - return false; + return true; } /** @@ -53,7 +53,7 @@ class PodcastPolicy */ public function update(User $user, Podcast $podcast) { - return false; + return !$podcast->locked; } /** @@ -65,7 +65,7 @@ class PodcastPolicy */ public function delete(User $user, Podcast $podcast) { - return false; + return !$podcast->locked; } /** @@ -77,7 +77,7 @@ class PodcastPolicy */ public function restore(User $user, Podcast $podcast) { - return false; + return !$podcast->locked; } /** @@ -89,6 +89,6 @@ class PodcastPolicy */ public function forceDelete(User $user, Podcast $podcast) { - return false; + return !$podcast->locked; } } diff --git a/database/migrations/2022_12_04_154911_create_podcasts_table.php b/database/migrations/2022_12_04_154911_create_podcasts_table.php index 759b87a1..8bbd14c5 100644 --- a/database/migrations/2022_12_04_154911_create_podcasts_table.php +++ b/database/migrations/2022_12_04_154911_create_podcasts_table.php @@ -16,10 +16,13 @@ class CreatePodcastsTable extends Migration $table->id(); $table->string('guid') ->unique(); + $table->boolean('locked') + ->default(true); $table->string('title'); $table->string('link'); $table->string('language_code'); - $table->json('data'); + $table->json('data') + ->nullable(); $table->timestamps(); }); } diff --git a/resources/views/livewire/frontend/search-by-tag-in-library.blade.php b/resources/views/livewire/frontend/search-by-tag-in-library.blade.php index a94518bd..b6e560a0 100644 --- a/resources/views/livewire/frontend/search-by-tag-in-library.blade.php +++ b/resources/views/livewire/frontend/search-by-tag-in-library.blade.php @@ -13,7 +13,7 @@ @endphp