Add Resources

Adding Resources from moodle
master
Paulo Vieira 2017-10-30 12:30:40 +00:00
parent 155b9231b3
commit e76449bbba
52 changed files with 206 additions and 1 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
laravel/.DS_Store vendored Normal file

Binary file not shown.

BIN
laravel/database/.DS_Store vendored Normal file

Binary file not shown.

View File

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

View File

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

View File

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

View File

@ -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,
];
}
}

View File

@ -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,
];
}
}

BIN
laravel/public/.DS_Store vendored Normal file

Binary file not shown.

BIN
laravel/public/img/0.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
laravel/public/img/1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
laravel/public/img/10.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
laravel/public/img/11.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
laravel/public/img/12.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
laravel/public/img/13.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
laravel/public/img/14.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
laravel/public/img/15.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
laravel/public/img/16.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
laravel/public/img/17.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
laravel/public/img/18.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
laravel/public/img/19.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
laravel/public/img/2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
laravel/public/img/20.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
laravel/public/img/21.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
laravel/public/img/22.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
laravel/public/img/23.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
laravel/public/img/24.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
laravel/public/img/25.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
laravel/public/img/26.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
laravel/public/img/27.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
laravel/public/img/28.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
laravel/public/img/29.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
laravel/public/img/3.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
laravel/public/img/30.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
laravel/public/img/31.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
laravel/public/img/32.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
laravel/public/img/33.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
laravel/public/img/34.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
laravel/public/img/35.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
laravel/public/img/36.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
laravel/public/img/37.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
laravel/public/img/38.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
laravel/public/img/39.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
laravel/public/img/4.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
laravel/public/img/40.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
laravel/public/img/5.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
laravel/public/img/6.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
laravel/public/img/7.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
laravel/public/img/8.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
laravel/public/img/9.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
laravel/public/img/empty.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

BIN
laravel/public/img/hidden.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B