new library added

This commit is contained in:
Benjamin Takats
2022-12-05 19:04:57 +01:00
parent 5735158927
commit b9265c3ec9
39 changed files with 1482 additions and 115 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use App\Models\Library;
class LibraryFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Library::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
return [
'name' => $this->faker->name,
'language_code' => $this->faker->word,
];
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use App\Models\Lecturer;
use App\Models\Library;
use App\Models\LibraryItems;
class LibraryItemsFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = LibraryItems::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
return [
'lecturer_id' => Lecturer::factory(),
'library_id' => Library::factory(),
'order_column' => $this->faker->randomNumber(),
'type' => $this->faker->word,
'value' => $this->faker->text,
];
}
}

View File

@@ -8,7 +8,6 @@ class CreateCountriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
@@ -17,13 +16,14 @@ class CreateCountriesTable extends Migration
$table->id();
$table->string('name');
$table->string('code');
$table->json('language_codes')
->default('[]');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLibrariesTable extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up(): void
{
Schema::create('libraries', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->json('language_codes')
->default('[]');
$table->timestamps();
});
}
/**
* Reverse the migrations.
* @return void
*/
public function down(): void
{
Schema::dropIfExists('libraries');
}
}

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLibraryItemsTable extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up(): void
{
Schema::disableForeignKeyConstraints();
Schema::create('library_items', function (Blueprint $table) {
$table->id();
$table->foreignId('lecturer_id')
->constrained()
->cascadeOnDelete()
->cascadeOnUpdate();
$table->unsignedInteger('order_column');
$table->string('name');
$table->string('type');
$table->string('language_code');
$table->longText('value');
$table->timestamps();
});
Schema::enableForeignKeyConstraints();
}
/**
* Reverse the migrations.
* @return void
*/
public function down(): void
{
Schema::dropIfExists('library_items');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLibraryLibraryItemTable extends Migration
{
/**
* Run the migrations.
* @return void
*/
public function up()
{
Schema::disableForeignKeyConstraints();
Schema::create('library_library_item', function (Blueprint $table) {
$table->foreignId('library_id')
->constrained()
->cascadeOnDelete()
->cascadeOnUpdate();
$table->foreignId('library_item_id')
->constrained()
->cascadeOnDelete()
->cascadeOnUpdate();
});
Schema::enableForeignKeyConstraints();
}
/**
* Reverse the migrations.
* @return void
*/
public function down()
{
Schema::dropIfExists('library_library_item');
}
}

View File

@@ -10,6 +10,8 @@ use App\Models\Country;
use App\Models\Course;
use App\Models\Event;
use App\Models\Lecturer;
use App\Models\Library;
use App\Models\LibraryItem;
use App\Models\Participant;
use App\Models\Registration;
use App\Models\Team;
@@ -49,16 +51,24 @@ class DatabaseSeeder extends Seeder
$user->current_team_id = $team->id;
$user->save();
Country::create([
'name' => 'Deutschland',
'code' => 'de',
'name' => 'Deutschland',
'code' => 'de',
'language_codes' => ['de'],
]);
Country::create([
'name' => 'Österreich',
'code' => 'at',
'name' => 'Österreich',
'code' => 'at',
'language_codes' => ['de'],
]);
Country::create([
'name' => 'Schweiz',
'code' => 'ch',
'name' => 'Schweiz',
'code' => 'ch',
'language_codes' => ['de'],
]);
Country::create([
'name' => 'France',
'code' => 'fr',
'language_codes' => ['fr'],
]);
City::create([
'country_id' => 1,
@@ -115,6 +125,16 @@ class DatabaseSeeder extends Seeder
'name' => 'Beppo',
'active' => true,
]);
Lecturer::create([
'team_id' => 1,
'name' => 'Helper',
'active' => true,
]);
Lecturer::create([
'team_id' => 1,
'name' => 'Gigi',
'active' => true,
]);
$category = Category::create([
'name' => 'Präsenzunterricht',
'slug' => str('Präsenzunterricht')->slug('-', 'de'),
@@ -127,21 +147,21 @@ class DatabaseSeeder extends Seeder
'lecturer_id' => 1,
'name' => 'Hands on Bitcoin',
]);
$course->syncTagsWithType(['Hardware Wallet'],'search');
$course->syncTagsWithType(['Hardware Wallet'], 'course');
$course->categories()
->attach($category);
$course = Course::create([
'lecturer_id' => 1,
'name' => 'Bitcoin <> Crypto',
]);
$course->syncTagsWithType(['Lightning'],'search');
$course->syncTagsWithType(['Lightning'], 'course');
$course->categories()
->attach($categoryOnline);
$course = Course::create([
'lecturer_id' => 2,
'name' => 'Bitcoin Lightning Network',
]);
$course->syncTagsWithType(['Für Unternehmen'],'search');
$course->syncTagsWithType(['Für Unternehmen'], 'course');
$course->categories()
->attach($categoryOnline);
Participant::create([
@@ -200,5 +220,45 @@ class DatabaseSeeder extends Seeder
'event_id' => 1,
'participant_id' => 1,
]);
$library = Library::create([
'name' => 'Einundzwanzig',
'language_codes' => ['de'],
]);
$libraryItem = LibraryItem::create([
'lecturer_id' => 3,
'name' => 'BITCOIN - Eine Reise in den Kaninchenbau🐇🕳',
'type' => 'youtube_video',
'language_code' => 'de',
'value' => 'https://www.youtube.com/watch?v=Oztd2Sja4k0',
]);
$libraryItem->syncTagsWithType(['Bitcoin'], 'library_item');
$library->libraryItems()
->attach($libraryItem);
$library = Library::create([
'name' => 'Apricot',
'language_codes' => ['de', 'en'],
]);
$libraryItem = LibraryItem::create([
'lecturer_id' => 4,
'name' => 'Liebe Krypto- und Fiat-Bros',
'type' => 'blog_article',
'language_code' => 'de',
'value' => 'https://aprycot.media/blog/liebe-krypto-und-fiat-bros/',
]);
$libraryItem->syncTagsWithType(['Bitcoin'], 'library_item');
$library->libraryItems()
->attach($libraryItem);
$library = Library::create([
'name' => 'Gigi',
'language_codes' => ['de', 'en'],
]);
$libraryItem = LibraryItem::create([
'lecturer_id' => 4,
'name' => 'Cryptography is Not Enough - Gigi @ Baltic Honeybadger 2022 ',
'type' => 'youtube_video',
'language_code' => 'de',
'value' => 'https://www.youtube.com/watch?v=C7ynm0Zkwfk',
]);
$libraryItem->syncTagsWithType(['Proof of Work'], 'library_item');
}
}