locked podcasts

This commit is contained in:
Benjamin Takats
2022-12-06 21:38:08 +01:00
parent 87010aabb9
commit caac426701
4 changed files with 27 additions and 9 deletions

View File

@@ -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'),

View File

@@ -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;
}
}

View File

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

View File

@@ -13,7 +13,7 @@
@endphp
<a
class="{{ $activeClass }} flex relative flex-col flex-shrink-0 justify-between py-1 px-3 w-full h-20 border-0 border-solid duration-300 ease-in-out cursor-pointer bg-opacity-[0.07]"
href="{{ route('library', ['country' => $country, 'table' => ['filters' => ['tag' => [$tag->id]]]]) }}"
href="{{ route(request()->route()->getName(), ['country' => $country, 'table' => ['filters' => ['tag' => [$tag->id]]]]) }}"
>
<div
class="flex flex-1 items-center p-0 m-0 text-center align-baseline border-0 border-solid"