|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class InitialStructure extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->string('nickname')->unique();
|
||||
$table->boolean('admin')->default(false);
|
||||
$table->boolean('blocked')->default(false);
|
||||
$table->string('reason_blocked')->nullable();
|
||||
$table->string('reason_reactivated')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('config', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('platform_email');
|
||||
$table->string('platform_email_properties');
|
||||
$table->string('img_base_path');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('images', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->enum('face', ['hidden', 'tile'])->default('tile');
|
||||
$table->boolean('active')->default(true);
|
||||
$table->string('path');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('games', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->enum('type', ['singleplayer', 'multiplayer']);
|
||||
$table->enum('status', ['pending', 'active', 'terminated', 'canceled'])->default('pending');
|
||||
$table->integer('total_players')->default(1);
|
||||
$table->integer('created_by')->unsigned();
|
||||
$table->foreign('created_by')->references('id')->on('users');
|
||||
$table->integer('winner')->unsigned()->nullable();
|
||||
$table->foreign('winner')->references('id')->on('users');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('game_user', function (Blueprint $table) {
|
||||
$table->integer('game_id')->unsigned();
|
||||
$table->foreign('game_id')->references('id')->on('games')->onDelete('cascade');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('game_user');
|
||||
Schema::dropIfExists('games');
|
||||
Schema::dropIfExists('images');
|
||||
Schema::dropIfExists('config');
|
||||
Schema::dropIfExists('password_resets');
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ConfigTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$platform_email = 'exemplo@mail.dad';
|
||||
$driver = 'smtp';
|
||||
$host = 'smtp.mailtrap.io';
|
||||
$port = 2525;
|
||||
$password = null;
|
||||
$encryption = null;
|
||||
$filesPath = 'tiles';
|
||||
$createdAt = Carbon\Carbon::now()->subMonths(2);
|
||||
|
||||
$configInfo = [
|
||||
'platform_email' => $platform_email,
|
||||
'platform_email_properties' => "{'driver': '$driver', 'host': '$host', 'port': $port, 'password': '$password', 'encryption': '$encryption' }",
|
||||
'img_base_path' => 'img/tiles/',
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $createdAt,
|
||||
];
|
||||
|
||||
DB::table('config')->insert($configInfo);
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,8 @@ class DatabaseSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call(UsersTableSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
$this->call(ConfigTableSeeder::class);
|
||||
$this->call(ImagesTableSeeder::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ImagesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function run()
|
||||
{
|
||||
$nbrTiles = 40;
|
||||
|
||||
for ($i = 0; $i <= $nbrTiles; ++$i) {
|
||||
DB::table('images')->insert($this->insertTile($i));
|
||||
}
|
||||
|
||||
DB::table('images')->insert($this->insertTile('hidden', 'hidden'));
|
||||
|
||||
}
|
||||
|
||||
private function insertTile($imgName, $face = 'tile')
|
||||
{
|
||||
$createdAt = Carbon\Carbon::now();
|
||||
|
||||
return [
|
||||
'face' => $face,
|
||||
'active' => true,
|
||||
'path' => $imgName . '.png',
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $createdAt,
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UsersTableSeeder extends Seeder
|
||||
{
|
||||
private $numberOfUsers = 30;
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$faker = Faker\Factory::create('pt_PT');
|
||||
|
||||
DB::table('users')->insert($this->fakeUser($faker, true));
|
||||
|
||||
for ($i = 0; $i < $this->numberOfUsers; ++$i) {
|
||||
DB::table('users')->insert($this->fakeUser($faker, false));
|
||||
}
|
||||
}
|
||||
|
||||
private function fakeUser(Faker\Generator $faker, $admin)
|
||||
{
|
||||
static $password;
|
||||
$createdAt = Carbon\Carbon::now()->subDays(30);
|
||||
$updatedAt = $faker->dateTimeBetween($createdAt);
|
||||
|
||||
$nickname = $admin ? 'admin' : $faker->unique()->userName;
|
||||
$email = $admin ? 'admin@mail.dad' : $faker->unique()->safeEmail;
|
||||
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'email' => $email,
|
||||
'password' => $password ?: $password = bcrypt('secret'),
|
||||
'nickname' => $nickname,
|
||||
'admin' => $admin,
|
||||
'blocked' => false,
|
||||
'reason_blocked' => null,
|
||||
'reason_reactivated' => null,
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $updatedAt,
|
||||
];
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 286 B |
After Width: | Height: | Size: 302 B |