podcasts added

This commit is contained in:
Benjamin Takats
2022-12-06 18:17:05 +01:00
parent a520c26dba
commit 85b2856bcd
30 changed files with 910 additions and 24 deletions

View 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' => '{}',
];
}
}

View 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' => '{}',
];
}
}

View File

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

View File

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

View File

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

View File

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

View File

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