generated from astrogoat/app-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,129 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
database/migrations/2024_08_25_115206_add_description_to_plays_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::table('plays', function (Blueprint $table) { | ||
$table->string('description')->after('published_year'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('plays', function (Blueprint $table) { | ||
$table->dropColumn('description'); | ||
}); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
database/migrations/2024_08_25_115806_create_genres_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('genres', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('genres'); | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_08_25_115951_create_genre_monologue_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Astrogoat\Monologues\Models\Genre; | ||
use Astrogoat\Monologues\Models\Monologue; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('genre_monologue', function (Blueprint $table) { | ||
$table->foreignIdFor(Genre::class)->constrained(); | ||
$table->foreignIdFor(Monologue::class)->constrained(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('genre_monologue'); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
database/migrations/2024_08_25_185539_create_identities_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('identities', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('identities'); | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_08_25_190039_create_identity_monologue_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Astrogoat\Monologues\Models\Monologue; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Astrogoat\Monologues\Models\Identity; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('identity_monologue', function (Blueprint $table) { | ||
$table->foreignIdFor(Identity::class)->constrained(); | ||
$table->foreignIdFor(Monologue::class)->constrained(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('identity_monologue'); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
database/migrations/2024_08_25_190152_create_ages_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('ages', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('ages'); | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_08_25_190239_create_age_monologue_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Astrogoat\Monologues\Models\Monologue; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Astrogoat\Monologues\Models\Age; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('age_monologue', function (Blueprint $table) { | ||
$table->foreignIdFor(Age::class)->constrained(); | ||
$table->foreignIdFor(Monologue::class)->constrained(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('age_monologue'); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
database/migrations/2024_08_25_194221_create_play_sources_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('play_sources', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('play_sources'); | ||
} | ||
}; |
23 changes: 23 additions & 0 deletions
23
database/migrations/2024_08_25_194321_create_play_play_sources_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use Astrogoat\Monologues\Models\Play; | ||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Astrogoat\Monologues\Models\PlaySource; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('play_play_source', function (Blueprint $table) { | ||
$table->foreignIdFor(Play::class)->constrained(); | ||
$table->foreignIdFor(PlaySource::class)->constrained(); | ||
$table->string('url')->nullable(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('play_play_source'); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
database/migrations/2024_08_25_203607_create_gender_identities_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('gender_identities', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('gender_identities'); | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_08_25_203707_create_gender_identity_monologue_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Astrogoat\Monologues\Models\Monologue; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Astrogoat\Monologues\Models\GenderIdentity; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('gender_identity_monologue', function (Blueprint $table) { | ||
$table->foreignIdFor(GenderIdentity::class)->constrained(); | ||
$table->foreignIdFor(Monologue::class)->constrained(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('gender_identity_monologue'); | ||
} | ||
}; |
88 changes: 88 additions & 0 deletions
88
database/migrations/2024_08_25_205442_migrate_play_and_monologue_data.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
use Astrogoat\Monologues\Models\Play; | ||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Astrogoat\Monologues\Models\Monologue; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
foreach (Monologue::withoutGlobalScopes()->get() as $monologue) { | ||
$this->convertSexToGenderIdentity($monologue); | ||
$this->convertIdentities($monologue); | ||
$this->convertAges($monologue); | ||
} | ||
|
||
foreach (Play::all() as $play) { | ||
$this->convertWhereToFindToSource($play); | ||
$this->convertPlayTypeToMonologueGenre($play); | ||
} | ||
|
||
Schema::table('plays', function (Blueprint $table) { | ||
$table->dropColumn('where_to_find'); | ||
$table->dropColumn('type'); | ||
}); | ||
|
||
Schema::table('monologues', function (Blueprint $table) { | ||
$table->dropColumn('sex'); | ||
$table->dropColumn('identity'); | ||
$table->dropColumn('type'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
// Schema::table('plays', function (Blueprint $table) { | ||
// $table->string('where_to_find')->nullable(); | ||
// }); | ||
} | ||
|
||
public function convertSexToGenderIdentity(Monologue $monologue): void | ||
{ | ||
$monologue->genderIdentities()->firstOrCreate(['name' => $monologue->sex->fullName()]); | ||
} | ||
|
||
public function convertAges(Monologue $monologue): void | ||
{ | ||
if ($monologue->age) { | ||
$monologue->ages()->firstOrCreate(['name' => trim($monologue->age)]); | ||
} | ||
} | ||
|
||
public function convertIdentities(Monologue $monologue): void | ||
{ | ||
$identities = Str::of($monologue->identity) | ||
->replace(',', ';') | ||
->explode(';') | ||
->filter() | ||
->map(fn ($identity) => trim($identity)) | ||
->filter(); | ||
|
||
foreach ($identities as $identity) { | ||
$monologue->identities()->firstOrCreate(['name' => $identity]); | ||
} | ||
} | ||
|
||
public function convertWhereToFindToSource(Play $play): void | ||
{ | ||
$sources = Str::of($play->where_to_find) | ||
->replace(',', ';') | ||
->explode(';') | ||
->filter() | ||
->map(fn ($source) => trim($source)) | ||
->filter(); | ||
|
||
foreach ($sources as $source) { | ||
$play->playSources()->firstOrCreate(['name' => $source]); | ||
} | ||
} | ||
|
||
public function convertPlayTypeToMonologueGenre(Play $play): void | ||
{ | ||
foreach ($play->monologues()->withoutGlobalScopes()->get() as $monologue) { | ||
$monologue->genres()->firstOrCreate(['name' => $play->type]); | ||
} | ||
} | ||
}; |
Oops, something went wrong.