mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
podcasts added
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
created: 'database/factories/LibraryFactory.php database/factories/LibraryItemsFactory.php database/migrations/2022_12_05_160932_create_libraries_table.php database/migrations/2022_12_05_160933_create_library_items_table.php app/Models/Library.php app/Models/LibraryItems.php app/Nova/Library.php app/Nova/LibraryItems.php'
|
||||
models:
|
||||
Category: { name: string, slug: string }
|
||||
City: { country_id: biginteger, name: string, slug: string, longitude: 'float:10', latitude: 'float:10' }
|
||||
Country: { name: string, code: string }
|
||||
Country: { name: string, code: string, language_codes: 'json default:[]' }
|
||||
Course: { lecturer_id: biginteger, name: string, description: 'text nullable' }
|
||||
Episode: { guid: string, podcast_id: biginteger, data: json }
|
||||
Event: { course_id: biginteger, venue_id: biginteger, '"from"': datetime, '"to"': datetime, link: string }
|
||||
Lecturer: { team_id: biginteger, name: string, slug: string, active: 'boolean default:1', description: 'text nullable' }
|
||||
Library: { name: string, language_code: string }
|
||||
LibraryItem: { lecturer_id: biginteger, library_id: biginteger, order_column: integer, type: string, value: text }
|
||||
Library: { name: string, is_public: 'boolean default:1', language_codes: 'json default:[]' }
|
||||
LibraryItem: { lecturer_id: biginteger, episode_id: 'biginteger nullable', order_column: integer, name: string, type: string, language_code: string, value: 'text nullable' }
|
||||
LoginKey: { k1: string, user_id: biginteger }
|
||||
Membership: { team_id: biginteger, user_id: biginteger, role: 'string nullable' }
|
||||
Participant: { first_name: string, last_name: string }
|
||||
Podcast: { guid: string, title: string, link: string, language_code: string, data: json }
|
||||
Registration: { event_id: biginteger, participant_id: biginteger, active: 'boolean default:1' }
|
||||
Tag: { name: json, slug: json, type: 'string nullable', order_column: 'integer nullable', icon: 'string default:tag' }
|
||||
Team: { user_id: biginteger, name: string, personal_team: boolean }
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Feed;
|
||||
|
||||
use App\Models\Episode;
|
||||
use App\Models\Podcast;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ReadAndSyncEinundzwanzigPodcastFeed extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'feed:sync';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$client = new \PodcastIndex\Client([
|
||||
'app' => 'Einundzwanzig School',
|
||||
'key' => config('feeds.services.podcastindex-org.key'),
|
||||
'secret' => config('feeds.services.podcastindex-org.secret'),
|
||||
]);
|
||||
$podcast = $client->podcasts->byFeedUrl('https://einundzwanzig.space/feed.xml')
|
||||
->json();
|
||||
$einundzwanzigPodcast = Podcast::query()
|
||||
->updateOrCreate(['guid' => $podcast->feed->podcastGuid], [
|
||||
'title' => $podcast->feed->title,
|
||||
'link' => $podcast->feed->link,
|
||||
'language_code' => $podcast->feed->language,
|
||||
'data' => $podcast->feed,
|
||||
]);
|
||||
$episodes = $client->episodes->byFeedUrl('https://einundzwanzig.space/feed.xml')
|
||||
->json();
|
||||
foreach ($episodes->items as $item) {
|
||||
Episode::query()
|
||||
->updateOrCreate(['guid' => $item->guid], [
|
||||
'podcast_id' => $einundzwanzigPodcast->id,
|
||||
'data' => $item,
|
||||
]);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Livewire\Frontend;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\Podcast;
|
||||
use Livewire\Component;
|
||||
|
||||
class Library extends Component
|
||||
@@ -24,13 +25,22 @@ class Library extends Component
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return view('livewire.frontend.library', [
|
||||
'libraries' => \App\Models\Library::query()
|
||||
$libraries = \App\Models\Library::query()
|
||||
->where('is_public', $shouldBePublic)
|
||||
->get()
|
||||
->prepend(\App\Models\Library::make([
|
||||
->get();
|
||||
$tabs = collect([
|
||||
[
|
||||
'name' => 'Alle',
|
||||
])),
|
||||
]
|
||||
]);
|
||||
foreach ($libraries as $library) {
|
||||
$tabs->push([
|
||||
'name' => $library->name,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('livewire.frontend.library', [
|
||||
'libraries' => $tabs,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class LibraryItemTable extends DataTableComponent
|
||||
'alt' => $row->name.' Avatar',
|
||||
])
|
||||
->collapseOnMobile(),
|
||||
Column::make('Dozent', "lecturer.name")
|
||||
Column::make('Ersteller', "lecturer.name")
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.courses.lecturer')->withRow($row)
|
||||
)
|
||||
|
||||
40
app/Models/Episode.php
Normal file
40
app/Models/Episode.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Spatie\Tags\HasTags;
|
||||
|
||||
class Episode extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasTags;
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'podcast_id' => 'integer',
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
public function podcast(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Podcast::class);
|
||||
}
|
||||
|
||||
public function libraryItem(): HasOne
|
||||
{
|
||||
return $this->hasOne(LibraryItem::class);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,11 @@ class LibraryItem extends Model implements HasMedia, Sortable
|
||||
return $this->belongsTo(Lecturer::class);
|
||||
}
|
||||
|
||||
public function episode(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Episode::class);
|
||||
}
|
||||
|
||||
public function libraries(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Library::class);
|
||||
|
||||
32
app/Models/Podcast.php
Normal file
32
app/Models/Podcast.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Podcast extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'data' => 'array',
|
||||
];
|
||||
|
||||
public function episodes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Episode::class);
|
||||
}
|
||||
}
|
||||
@@ -13,4 +13,9 @@ class Tag extends \Spatie\Tags\Tag
|
||||
{
|
||||
return $this->morphedByMany(LibraryItem::class, 'taggable');
|
||||
}
|
||||
|
||||
public function episodes()
|
||||
{
|
||||
return $this->morphedByMany(Episode::class, 'taggable');
|
||||
}
|
||||
}
|
||||
|
||||
156
app/Nova/Episode.php
Normal file
156
app/Nova/Episode.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\Avatar;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\Code;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Spatie\TagsField\Tags;
|
||||
|
||||
class Episode extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
* @var string
|
||||
*/
|
||||
public static $model = \App\Models\Episode::class;
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'id',
|
||||
];
|
||||
|
||||
public static function afterUpdate(NovaRequest $request, Model $model)
|
||||
{
|
||||
if ($request->tags) {
|
||||
$lecturer = \App\Models\Lecturer::updateOrCreate(['name' => $model->podcast->title], [
|
||||
'team_id' => 1,
|
||||
'active' => true,
|
||||
]);
|
||||
$lecturer->addMediaFromUrl($model->podcast->data['image'])
|
||||
->toMediaCollection('avatar');
|
||||
$library = \App\Models\Library::updateOrCreate(
|
||||
[
|
||||
'name' => $model->podcast->title
|
||||
],
|
||||
[
|
||||
'language_codes' => [$model->podcast->language_code],
|
||||
]);
|
||||
$libraryItem = $model->libraryItem()
|
||||
->firstOrCreate([
|
||||
'lecturer_id' => $lecturer->id,
|
||||
'episode_id' => $model->id,
|
||||
'name' => $model->data['title'],
|
||||
'type' => 'podcast_episode',
|
||||
'language_code' => $model->podcast->language_code,
|
||||
'value' => null,
|
||||
]);
|
||||
ray($request->tags);
|
||||
$libraryItem->syncTagsWithType(is_array($request->tags) ? $request->tags : str($request->tags)->explode('-----'),
|
||||
'library_item');
|
||||
$libraryItem->addMediaFromUrl($model->data['image'])
|
||||
->toMediaCollection('main');
|
||||
$library->libraryItems()
|
||||
->attach($libraryItem);
|
||||
}
|
||||
}
|
||||
|
||||
public function title()
|
||||
{
|
||||
return $this->data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields(Request $request)
|
||||
{
|
||||
return [
|
||||
ID::make()
|
||||
->sortable(),
|
||||
|
||||
Avatar::make('Image')
|
||||
->squared()
|
||||
->thumbnail(function () {
|
||||
return $this->data['image'];
|
||||
})
|
||||
->exceptOnForms(),
|
||||
|
||||
Tags::make('Tags')
|
||||
->type('library_item')
|
||||
->withLinkToTagResource(Tag::class),
|
||||
|
||||
Text::make('Title', 'data->title')
|
||||
->readonly()
|
||||
->rules('required', 'string'),
|
||||
|
||||
Code::make('Data')
|
||||
->readonly()
|
||||
->rules('required', 'json')
|
||||
->json(),
|
||||
|
||||
BelongsTo::make('Podcast')
|
||||
->readonly(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cards(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filters(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function lenses(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function actions(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@ class LibraryItem extends Resource
|
||||
'markdown_article' => 'markdown_article',
|
||||
'youtube_video' => 'youtube_video',
|
||||
'vimeo_video' => 'vimeo_video',
|
||||
'podcast_episode' => 'podcast_episode',
|
||||
'downloadable_file' => 'downloadable_file',
|
||||
]
|
||||
)
|
||||
@@ -91,6 +92,8 @@ class LibraryItem extends Resource
|
||||
|
||||
BelongsTo::make('Lecturer'),
|
||||
|
||||
BelongsTo::make('Episode'),
|
||||
|
||||
BelongsToMany::make('Library', 'libraries', Library::class),
|
||||
|
||||
];
|
||||
|
||||
118
app/Nova/Podcast.php
Normal file
118
app/Nova/Podcast.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\Avatar;
|
||||
use Laravel\Nova\Fields\Code;
|
||||
use Laravel\Nova\Fields\HasMany;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
|
||||
class Podcast extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
* @var string
|
||||
*/
|
||||
public static $model = \App\Models\Podcast::class;
|
||||
|
||||
/**
|
||||
* The single value that should be used to represent the resource when being displayed.
|
||||
* @var string
|
||||
*/
|
||||
public static $title = 'title';
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'id',
|
||||
'title',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields(Request $request)
|
||||
{
|
||||
return [
|
||||
ID::make()
|
||||
->sortable(),
|
||||
|
||||
Avatar::make('Image')
|
||||
->squared()
|
||||
->thumbnail(function () {
|
||||
return $this->data['image'];
|
||||
}),
|
||||
|
||||
Text::make('Title')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Text::make('Language Code')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Text::make('Link')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Code::make('Data')
|
||||
->rules('required', 'json')
|
||||
->json(),
|
||||
|
||||
HasMany::make('Episodes'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cards(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filters(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function lenses(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function actions(Request $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
68
app/Observers/EpisodeObserver.php
Normal file
68
app/Observers/EpisodeObserver.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Episode;
|
||||
|
||||
class EpisodeObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Episode "created" event.
|
||||
*
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function created(Episode $episode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Episode "updated" event.
|
||||
*
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updated(Episode $episode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Episode "deleted" event.
|
||||
*
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(Episode $episode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Episode "restored" event.
|
||||
*
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function restored(Episode $episode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Episode "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(Episode $episode)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
101
app/Policies/EpisodePolicy.php
Normal file
101
app/Policies/EpisodePolicy.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Episode;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class EpisodePolicy extends BasePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function viewAny(User $user)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function view(User $user, Episode $episode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function update(User $user, Episode $episode)
|
||||
{
|
||||
return $user->hasRole('super-admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function delete(User $user, Episode $episode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function restore(User $user, Episode $episode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Episode $episode
|
||||
*
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function forceDelete(User $user, Episode $episode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
94
app/Policies/PodcastPolicy.php
Normal file
94
app/Policies/PodcastPolicy.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Podcast;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class PodcastPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function viewAny(User $user)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Podcast $podcast
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function view(User $user, Podcast $podcast)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Podcast $podcast
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function update(User $user, Podcast $podcast)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Podcast $podcast
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function delete(User $user, Podcast $podcast)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Podcast $podcast
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function restore(User $user, Podcast $podcast)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Podcast $podcast
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function forceDelete(User $user, Podcast $podcast)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Episode;
|
||||
use App\Observers\EpisodeObserver;
|
||||
use App\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Observers\EventObserver;
|
||||
use App\Observers\EpisodeObserver;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
@@ -23,17 +21,15 @@ class EventServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
\App\Models\Event::observe(EventObserver::class);
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldDiscoverEvents()
|
||||
|
||||
@@ -7,11 +7,13 @@ use App\Nova\City;
|
||||
use App\Nova\Country;
|
||||
use App\Nova\Course;
|
||||
use App\Nova\Dashboards\Main;
|
||||
use App\Nova\Episode;
|
||||
use App\Nova\Event;
|
||||
use App\Nova\Lecturer;
|
||||
use App\Nova\Library;
|
||||
use App\Nova\LibraryItem;
|
||||
use App\Nova\Participant;
|
||||
use App\Nova\Podcast;
|
||||
use App\Nova\Registration;
|
||||
use App\Nova\Tag;
|
||||
use App\Nova\Team;
|
||||
@@ -59,6 +61,13 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
||||
->icon('library')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Podcasts', [
|
||||
MenuItem::resource(Podcast::class),
|
||||
MenuItem::resource(Episode::class),
|
||||
])
|
||||
->icon('microphone')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Admin', [
|
||||
MenuItem::resource(Category::class),
|
||||
MenuItem::resource(Country::class),
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"laravel/tinker": "^2.7",
|
||||
"livewire/livewire": "^2.5",
|
||||
"nova/start": "*",
|
||||
"podcastindex/podcastindex-php": "^1.0",
|
||||
"rappasoft/laravel-livewire-tables": "^2.8",
|
||||
"sentry/sentry-laravel": "^3.1",
|
||||
"simplesoftwareio/simple-qrcode": "^4.2",
|
||||
|
||||
33
composer.lock
generated
33
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": "fe13b4c19e33aebc3926e4dcd5ddf8e8",
|
||||
"content-hash": "9c4898684e578e46bb709340edf618e8",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akuechler/laravel-geoly",
|
||||
@@ -4941,6 +4941,37 @@
|
||||
},
|
||||
"time": "2021-10-28T11:13:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "podcastindex/podcastindex-php",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LowSociety/podcastindex-php.git",
|
||||
"reference": "8aa323cf67e1892c8ebec4500803fb8bf14ba84b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/LowSociety/podcastindex-php/zipball/8aa323cf67e1892c8ebec4500803fb8bf14ba84b",
|
||||
"reference": "8aa323cf67e1892c8ebec4500803fb8bf14ba84b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PodcastIndex\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"description": "A PHP wrapper for the PodcastIndex API.",
|
||||
"support": {
|
||||
"issues": "https://github.com/LowSociety/podcastindex-php/issues",
|
||||
"source": "https://github.com/LowSociety/podcastindex-php/tree/1.0.0"
|
||||
},
|
||||
"time": "2020-09-10T10:09:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pragmarx/google2fa",
|
||||
"version": "v8.0.1",
|
||||
|
||||
8
config/feeds/services.php
Normal file
8
config/feeds/services.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'podcastindex-org' => [
|
||||
'key' => env('PODCASTINDEX_ORG_KEY'),
|
||||
'secret' => env('PODCASTINDEX_ORG_SECRET'),
|
||||
]
|
||||
];
|
||||
31
database/factories/EpisodeFactory.php
Normal file
31
database/factories/EpisodeFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Podcast;
|
||||
|
||||
class EpisodeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Episode::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'podcast_id' => Podcast::factory(),
|
||||
'data' => '{}',
|
||||
];
|
||||
}
|
||||
}
|
||||
31
database/factories/PodcastFactory.php
Normal file
31
database/factories/PodcastFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Podcast;
|
||||
|
||||
class PodcastFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Podcast::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'title' => $this->faker->sentence(4),
|
||||
'link' => $this->faker->word,
|
||||
'data' => '{}',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePodcastsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('podcasts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('guid')
|
||||
->unique();
|
||||
$table->string('title');
|
||||
$table->string('link');
|
||||
$table->string('language_code');
|
||||
$table->json('data');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('podcasts');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateEpisodesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::disableForeignKeyConstraints();
|
||||
|
||||
Schema::create('episodes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('guid')
|
||||
->unique();
|
||||
$table->foreignId('podcast_id')
|
||||
->constrained()
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
$table->json('data');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::enableForeignKeyConstraints();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('episodes');
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class CreateLibrariesTable extends Migration
|
||||
{
|
||||
Schema::create('libraries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('name')->unique();
|
||||
$table->boolean('is_public')
|
||||
->default(true);
|
||||
$table->json('language_codes')
|
||||
|
||||
@@ -20,6 +20,11 @@ class CreateLibraryItemsTable extends Migration
|
||||
->constrained()
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
$table->foreignId('episode_id')
|
||||
->nullable()
|
||||
->constrained()
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
$table->unsignedInteger('order_column');
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
||||
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use App\Console\Commands\Database\CreateTags;
|
||||
use App\Console\Commands\Feed\ReadAndSyncEinundzwanzigPodcastFeed;
|
||||
use App\Models\Category;
|
||||
use App\Models\City;
|
||||
use App\Models\Country;
|
||||
@@ -277,5 +278,6 @@ class DatabaseSeeder extends Seeder
|
||||
$libraryItem->syncTagsWithType(['Präsentationen'], 'library_item');
|
||||
$nonPublicLibrary->libraryItems()
|
||||
->attach($libraryItem);
|
||||
Artisan::call(ReadAndSyncEinundzwanzigPodcastFeed::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,10 @@
|
||||
Download
|
||||
</x-button>
|
||||
@endif
|
||||
@if($row->type === 'podcast_episode')
|
||||
<x-button amber href="{{ $row->episode->data['enclosureUrl'] }}" target="_blank">
|
||||
<i class="fa fa-thin fa-headphones mr-2"></i>
|
||||
Anhören
|
||||
</x-button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="flex items-center">
|
||||
<div class="flex flex-wrap items-center">
|
||||
@foreach($row->tags as $tag)
|
||||
<x-badge>{{ $tag->name }}</x-badge>
|
||||
<x-badge class="whitespace-nowrap m-1">{{ $tag->name }}</x-badge>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
<nav class="-mb-px flex space-x-8">
|
||||
@foreach($libraries as $library)
|
||||
@php
|
||||
$currentLibraryClass = $currentTab === $library->name ? 'border-amber-500 text-amber-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300';
|
||||
$currentLibraryClass = $currentTab === $library['name'] ? 'border-amber-500 text-amber-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300';
|
||||
@endphp
|
||||
<a href="{{ route(request()->route()->getName(), ['country' => $country, 'currentTab' => $library->name]) }}"
|
||||
class="{{ $currentLibraryClass }} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm">{{ $library->name }}</a>
|
||||
<a href="{{ route(request()->route()->getName(), ['country' => $country, 'currentTab' => $library['name']]) }}"
|
||||
class="{{ $currentLibraryClass }} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm">{{ $library['name'] }}</a>
|
||||
@endforeach
|
||||
</nav>
|
||||
</div>
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
<livewire:frontend.search-by-tag-in-library/>
|
||||
<div class="my-12">
|
||||
|
||||
<livewire:tables.library-item-table :currentTab="$currentTab"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user