Initial Commit
This commit is contained in:
commit
ddf09fe00c
113 changed files with 187148 additions and 0 deletions
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
*.sqlite*
|
||||
62
database/factories/CardFactory.php
Normal file
62
database/factories/CardFactory.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Models\Raid;
|
||||
use App\Models\Card as Model;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class CardFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$words = $this->faker->words(10);
|
||||
$words[rand(0, count($words)-1)] = '?';
|
||||
|
||||
return [
|
||||
'raid_id' => null,
|
||||
'character_id' => null,
|
||||
'body' => join(" ", $words)
|
||||
];
|
||||
}
|
||||
|
||||
public function random_character()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'raid_id' => Character::all()->random()->id,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function random_class()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'class' => $this->faker->randomElement(['warrior', 'rogue', 'paladin', 'mage', 'warlock', 'shaman', 'druid', 'priest']),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function random_raid()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'raid_id' => Raid::factory(),
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
40
database/factories/CharacterFactory.php
Normal file
40
database/factories/CharacterFactory.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Card;
|
||||
use App\Models\Character as Model;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class CharacterFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->firstName(),
|
||||
];
|
||||
}
|
||||
|
||||
public function cards($count)
|
||||
{
|
||||
$cards = Card::factory()
|
||||
->count($count)
|
||||
->state(function (array $attr) {
|
||||
return ['class' => null ];
|
||||
});
|
||||
|
||||
return $this->has($cards);
|
||||
}
|
||||
}
|
||||
28
database/factories/RaidFactory.php
Normal file
28
database/factories/RaidFactory.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Raid as Model;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class RaidFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->text(64),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
database/factories/SettingFactory.php
Normal file
28
database/factories/SettingFactory.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Setting as Model;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SettingFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'value' => [ 'asdf' => 123]
|
||||
];
|
||||
}
|
||||
}
|
||||
50
database/migrations/2021_09_13_000000_base.php
Normal file
50
database/migrations/2021_09_13_000000_base.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class Base extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->json('value');
|
||||
});
|
||||
|
||||
Schema::create('characters', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('raids', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('cards', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('character_id')->nullable()->constrained();
|
||||
$table->foreignId('raid_id')->nullable()->constrained();
|
||||
$table->enum('role', ['tank', 'healer', 'dps'])->nullable();
|
||||
$table->enum('class', ['warrior', 'rogue', 'paladin', 'hunter', 'mage', 'warlock', 'shaman', 'druid', 'priest'])->nullable();
|
||||
$table->string('body');
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('card_raids', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('raid_id')->constrained();
|
||||
$table->foreignId('card_id')->constrained();
|
||||
});
|
||||
}
|
||||
}
|
||||
30
database/seeders/CardSeeder.php
Normal file
30
database/seeders/CardSeeder.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Card;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CardSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Card::factory(25)
|
||||
->random_class()
|
||||
->create();
|
||||
|
||||
Card::factory(10)
|
||||
->random_class()
|
||||
->random_raid()
|
||||
->create();
|
||||
|
||||
Card::factory(15)
|
||||
->random_raid()
|
||||
->create();
|
||||
}
|
||||
}
|
||||
28
database/seeders/DatabaseSeeder.php
Normal file
28
database/seeders/DatabaseSeeder.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call(RaidSeeder::class);
|
||||
|
||||
$this->call(CardSeeder::class);
|
||||
|
||||
Character::factory(30)
|
||||
->cards(10)
|
||||
->create();
|
||||
|
||||
Setting::factory(10)->create();
|
||||
}
|
||||
}
|
||||
23
database/seeders/RaidSeeder.php
Normal file
23
database/seeders/RaidSeeder.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Raid;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RaidSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//$raids = [ 'Karazhan', 'Grul\'s Lair', 'Magtheridon', 'SSC', 'TK' ];
|
||||
|
||||
//foreach($raids as $name) {
|
||||
//Raid::insert(['name' => $name ]);
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in a new issue