update code
This commit is contained in:
2
database/.gitignore
vendored
Normal file
2
database/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.sqlite
|
||||
*.sqlite-journal
|
||||
19
database/factories/AttachmentFactory.php
Normal file
19
database/factories/AttachmentFactory.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\Entities\Attachment;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Entities\Document;
|
||||
|
||||
$factory->define(Attachment::class, function (Faker $faker) {
|
||||
$exts = ['doc', 'docx', 'xls', 'xlsx', 'png', 'jpg'];
|
||||
return [
|
||||
'document_id' => Document::all()->random()->id,
|
||||
'name' => $name = Str::random(rand(10, 30)),
|
||||
'extension' => $ext = $exts[array_rand($exts)],
|
||||
'size' => rand(0, 99),
|
||||
'path' => 'attachemts/'.$name.'.'.$ext,
|
||||
];
|
||||
});
|
||||
11
database/factories/DocumentFactory.php
Normal file
11
database/factories/DocumentFactory.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\Entities\Document;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(Document::class, function (Faker $faker) {
|
||||
$faker->addProvider(new App\Fakers\AbstractDocumentFacker($faker));
|
||||
return $faker->document();
|
||||
});
|
||||
34
database/factories/UserFactory.php
Normal file
34
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\Entities\User;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Entities\Department;
|
||||
use App\Entities\Title;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This directory should contain each of the model factory definitions for
|
||||
| your application. Factories provide a convenient way to generate new
|
||||
| model instances for testing / seeding your application's database.
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(User::class, function (Faker $faker) {
|
||||
$name = $faker->name;
|
||||
return [
|
||||
'name' => Str::contains($name, '.') ? explode('.', $name)[1] : $name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'tel' => $faker->phoneNumber,
|
||||
'birthday' => $faker->date($format = 'Y-m-d', $max = 'now'),
|
||||
'department_id' => Department::all()->random()->id,
|
||||
'title_id' => Title::all()->random()->id,
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePersonalAccessTokensTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('tokenable_type');
|
||||
$table->string('tokenable_id');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePermissionTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
|
||||
$table->string('model_type');
|
||||
$table->string($columnNames['model_morph_key'], 20);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign('permission_id')
|
||||
->references('id')
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) {
|
||||
$table->unsignedBigInteger('role_id');
|
||||
|
||||
$table->string('model_type');
|
||||
$table->string($columnNames['model_morph_key'], 20);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign('role_id')
|
||||
->references('id')
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
$table->unsignedBigInteger('role_id');
|
||||
|
||||
$table->foreign('permission_id')
|
||||
->references('id')
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('role_id')
|
||||
->references('id')
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', 'role_id'], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateDepartmentsTable.
|
||||
*/
|
||||
class CreateDepartmentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('departments', function(Blueprint $table) {
|
||||
$table->string('id', 7)->primary();
|
||||
$table->string('name');
|
||||
$table->string('tel');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('departments');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateTitlesTable.
|
||||
*/
|
||||
class CreateTitlesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('titles', function(Blueprint $table) {
|
||||
$table->string('id', 5)->primary();
|
||||
$table->string('name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('titles');
|
||||
}
|
||||
}
|
||||
50
database/migrations/2020_04_30_040100_create_users_table.php
Normal file
50
database/migrations/2020_04_30_040100_create_users_table.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->string('id', 20)->primary();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('tel')->unique();
|
||||
$table->date('birthday')->nullable();
|
||||
$table->string('department_id', 7);
|
||||
$table->string('title_id', 5);
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->boolean('active')->default(true);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('department_id')
|
||||
->references('id')
|
||||
->on('departments')
|
||||
->onUpdate('cascade');
|
||||
$table->foreign('title_id')
|
||||
->references('id')
|
||||
->on('titles')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
33
database/migrations/2020_04_30_040945_create_books_table.php
Normal file
33
database/migrations/2020_04_30_040945_create_books_table.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateBooksTable.
|
||||
*/
|
||||
class CreateBooksTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('books', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('books');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateDocumentTypesTable.
|
||||
*/
|
||||
class CreateDocumentTypesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('document_types', function(Blueprint $table) {
|
||||
$table->string('id', 2)->primary();
|
||||
$table->string('name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('document_types');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateSignersTable.
|
||||
*/
|
||||
class CreateSignersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('signers', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('signers');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateOrganizesTable.
|
||||
*/
|
||||
class CreateOrganizesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('organizes', function(Blueprint $table) {
|
||||
$table->string('id', 30)->primary();
|
||||
$table->string('name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('organizes');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateDocumentsTable.
|
||||
*/
|
||||
class CreateDocumentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('documents', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('symbol', 30)->nullable();
|
||||
$table->text('abstract')->nullable();
|
||||
$table->unsignedInteger('book_id');
|
||||
$table->string('type_id', 2);
|
||||
$table->unsignedInteger('signer_id')->nullable();
|
||||
$table->date('sign_at')->nullable();
|
||||
$table->string('creator_id', 20);
|
||||
$table->string('writer_id', 20)->nullable();
|
||||
$table->date('effective_at');
|
||||
$table->string('publisher_id', 30);
|
||||
$table->unsignedInteger('link_id')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('book_id')
|
||||
->references('id')
|
||||
->on('books')
|
||||
->onUpdate('cascade');
|
||||
$table->foreign('type_id')
|
||||
->references('id')
|
||||
->on('document_types')
|
||||
->onUpdate('cascade');
|
||||
$table->foreign('signer_id')
|
||||
->references('id')
|
||||
->on('signers')
|
||||
->onUpdate('cascade');
|
||||
$table->foreign('creator_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onUpdate('cascade');
|
||||
$table->foreign('writer_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onUpdate('cascade');
|
||||
$table->foreign('publisher_id')
|
||||
->references('id')
|
||||
->on('organizes')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->foreign('link_id')
|
||||
->references('id')
|
||||
->on('documents')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('documents');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateDocumentReceiversTable.
|
||||
*/
|
||||
class CreateDocumentReceiversTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('document_receivers', function(Blueprint $table) {
|
||||
$table->string('user_id', 20);
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->boolean('seen')->default(false);
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary(['user_id', 'document_id']);
|
||||
$table->foreign('user_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onUpdate('cascade');
|
||||
$table->foreign('document_id')
|
||||
->references('id')
|
||||
->on('documents')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('document_receivers');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateAttachmentsTable.
|
||||
*/
|
||||
class CreateAttachmentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('attachments', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('name');
|
||||
$table->string('extension');
|
||||
$table->decimal('size', 5, 2);
|
||||
$table->text('path');
|
||||
$table->unsignedInteger('downloads')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('document_id')
|
||||
->references('id')
|
||||
->on('documents')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('attachments');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateNotificationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->string('notifiable_type');
|
||||
$table->string('notifiable_id');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['notifiable_type', 'notifiable_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
}
|
||||
36
database/migrations/2020_05_19_151733_create_jobs_table.php
Normal file
36
database/migrations/2020_05_19_151733_create_jobs_table.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Class CreateDocumentOrganizesTable.
|
||||
*/
|
||||
class CreateDocumentOrganizesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('document_organizes', function(Blueprint $table) {
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('organize_id', 30);
|
||||
|
||||
$table->primary(['document_id', 'organize_id']);
|
||||
$table->foreign('document_id')
|
||||
->references('id')
|
||||
->on('documents')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade');
|
||||
$table->foreign('organize_id')
|
||||
->references('id')
|
||||
->on('organizes')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('document_organizes');
|
||||
}
|
||||
}
|
||||
20
database/seeds/BookSeeder.php
Normal file
20
database/seeds/BookSeeder.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class BookSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('books')->insert([
|
||||
['name' => 'Văn bản đến'],
|
||||
['name' => 'Văn bản đi'],
|
||||
['name' => 'Văn bản nội bộ'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
24
database/seeds/DatabaseSeeder.php
Normal file
24
database/seeds/DatabaseSeeder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->call(DepartmentSeeder::class);
|
||||
$this->call(TitleSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(PermissionSeeder::class);
|
||||
$this->call(BookSeeder::class);
|
||||
$this->call(DocumentTypeSeeder::class);
|
||||
$this->call(OrganizeSeeder::class);
|
||||
$this->call(SignerSeeder::class);
|
||||
$this->call(DocumentSeeder::class);
|
||||
}
|
||||
}
|
||||
35
database/seeds/DepartmentSeeder.php
Normal file
35
database/seeds/DepartmentSeeder.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DepartmentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('departments')->insert([
|
||||
['id' => 'BGD', 'name' => 'Ban Giám đốc', 'tel' => '0123456600'],
|
||||
['id' => 'PKHSX', 'name' => 'Phòng Kế hoạch - Sản xuất', 'tel' => '0123456700'],
|
||||
['id' => 'PTCLD', 'name' => 'Phòng Tổ chức - Lao động', 'tel' => '0123456701'],
|
||||
['id' => 'PTC', 'name' => 'Phòng Tài chính', 'tel' => '0123456702'],
|
||||
['id' => 'PKTCN', 'name' => 'Phòng Kỹ thuật - Công nghệ', 'tel' => '0123456703'],
|
||||
['id' => 'PVT', 'name' => 'Phòng Vật tư', 'tel' => '0123456704'],
|
||||
['id' => 'PKCS', 'name' => 'Phòng KCS', 'tel' => '0123456705'],
|
||||
['id' => 'PHCHC', 'name' => 'Phòng Hành chính - Hậu cần', 'tel' => '0123456706'],
|
||||
['id' => 'PCT', 'name' => 'Phòng Chính trị', 'tel' => '0123456707'],
|
||||
['id' => 'PTKCN', 'name' => 'Phòng Thiết Kế - Công Nghệ', 'tel' => '0123456708'],
|
||||
['id' => 'BATLD', 'name' => 'Ban An Toàn Lao Động', 'tel' => '0123456709'],
|
||||
['id' => 'XDL', 'name' => 'Phân xưởng Động lực', 'tel' => '0123456710'],
|
||||
['id' => 'XVT', 'name' => 'Phân xưởng Vỏ tàu', 'tel' => '0123456711'],
|
||||
['id' => 'XDTCD', 'name' => 'Phân xưởng Điện tàu - Cơ điện', 'tel' => '0123456712'],
|
||||
['id' => 'XCK', 'name' => 'Phân xưởng Cơ khí', 'tel' => '0123456713'],
|
||||
['id' => 'XDD', 'name' => 'Phân xưởng Đà đốc', 'tel' => '0123456714'],
|
||||
['id' => 'XVKKTDT', 'name' => 'Phân xưởng VK-KTĐT', 'tel' => '0123456715'],
|
||||
['id' => 'XO', 'name' => 'Phân xưởng Ống', 'tel' => '0123456716'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
17
database/seeds/DocumentSeeder.php
Normal file
17
database/seeds/DocumentSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DocumentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
factory(App\Entities\Document::class, 100)->create();
|
||||
factory(App\Entities\Attachment::class, 20)->create();
|
||||
}
|
||||
}
|
||||
24
database/seeds/DocumentTypeSeeder.php
Normal file
24
database/seeds/DocumentTypeSeeder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DocumentTypeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('document_types')->insert([
|
||||
['id' => 'BC', 'name' => 'Báo cáo'],
|
||||
['id' => 'CV', 'name' => 'Công văn'],
|
||||
['id' => 'HD', 'name' => 'Hướng dẫn'],
|
||||
['id' => 'KH', 'name' => 'Kế hoạch'],
|
||||
['id' => 'NQ', 'name' => 'Nghị quyết'],
|
||||
['id' => 'ND', 'name' => 'Nghị định'],
|
||||
['id' => 'QD', 'name' => 'Quyết định'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
25
database/seeds/OrganizeSeeder.php
Normal file
25
database/seeds/OrganizeSeeder.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OrganizeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('organizes')->insert([
|
||||
['id' => 'HS', 'name' => 'Công ty Hải Sơn'],
|
||||
['id' => 'TCHQ', 'name' => 'Tổng cục Hải quán'],
|
||||
['id' => 'BTC', 'name' => 'Bộ Tài chính'],
|
||||
['id' => 'BCT', 'name' => 'Bộ Công Thương'],
|
||||
['id' => 'VPTT', 'name' => 'Văn phòng Thường trực BCĐ 389 quốc gia'],
|
||||
['id' => 'BTNMT', 'name' => 'Bộ Tài nguyên môi trường'],
|
||||
['id' => 'BQP', 'name' => 'Bộ Quốc phòng'],
|
||||
['id' => 'SHC', 'name' => 'Sở Hành Chính thành phố Đà Nẵng'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
96
database/seeds/PermissionSeeder.php
Normal file
96
database/seeds/PermissionSeeder.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Entities\User;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$guard = config('auth.defaults.guard');
|
||||
|
||||
DB::table(config('permission.table_names.permissions'))->insert([
|
||||
['name' => 'Quản lý chức danh', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý người dùng', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý phòng ban', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý nhóm', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý người ký', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý nơi ban hành', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý loại văn bản', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý quyền', 'guard_name' => $guard],
|
||||
['name' => 'Phân quyền', 'guard_name' => $guard],
|
||||
['name' => 'Báo cáo thống kê', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý văn bản đến', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý văn bản đi', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý văn bản nội bộ', 'guard_name' => $guard],
|
||||
['name' => 'Quản lý sổ văn bản', 'guard_name' => $guard],
|
||||
]);
|
||||
|
||||
DB::table(config('permission.table_names.roles'))->insert([
|
||||
['name' => 'Lãnh đạo phòng', 'guard_name' => $guard],
|
||||
['name' => 'Chuyên viên', 'guard_name' => $guard],
|
||||
['name' => 'Quản trị hệ thống', 'guard_name' => $guard],
|
||||
['name' => 'Văn thư', 'guard_name' => $guard],
|
||||
]);
|
||||
|
||||
Role::find(1)->syncPermissions([
|
||||
'Quản lý chức danh',
|
||||
'Quản lý người dùng',
|
||||
'Quản lý phòng ban',
|
||||
'Quản lý người ký',
|
||||
'Quản lý nơi ban hành',
|
||||
'Quản lý quyền',
|
||||
'Phân quyền',
|
||||
'Báo cáo thống kê',
|
||||
]);
|
||||
|
||||
Role::find(3)->syncPermissions([
|
||||
'Quản lý chức danh',
|
||||
'Quản lý người dùng',
|
||||
'Quản lý phòng ban',
|
||||
'Quản lý người ký',
|
||||
'Quản lý nơi ban hành',
|
||||
'Phân quyền',
|
||||
'Quản lý quyền',
|
||||
'Quản lý nhóm',
|
||||
'Báo cáo thống kê',
|
||||
'Quản lý văn bản đến',
|
||||
'Quản lý văn bản đi',
|
||||
'Quản lý văn bản nội bộ',
|
||||
'Quản lý loại văn bản',
|
||||
'Quản lý sổ văn bản',
|
||||
]);
|
||||
|
||||
Role::find(4)->syncPermissions([
|
||||
'Báo cáo thống kê',
|
||||
'Quản lý văn bản đến',
|
||||
'Quản lý văn bản đi',
|
||||
'Quản lý văn bản nội bộ',
|
||||
'Quản lý loại văn bản',
|
||||
'Quản lý sổ văn bản',
|
||||
]);
|
||||
|
||||
for ($i=0; $i < 10; $i++) {
|
||||
User::where('department_id', 'PKTCN')->get()->random()->assignRole();
|
||||
}
|
||||
|
||||
for ($i=0; $i < 10; $i++) {
|
||||
User::where('department_id', 'PHCHC')->get()->random()->assignRole();
|
||||
}
|
||||
|
||||
for ($i=0; $i < 50; $i++) {
|
||||
User::whereNotIn('department_id', ['PKTCN', 'PHCHC'])
|
||||
->get()
|
||||
->random()
|
||||
->assignRole(Role::all()->random()->id);
|
||||
}
|
||||
|
||||
User::find('PKTCN-TP-1')->assignRole('Quản trị hệ thống');
|
||||
}
|
||||
}
|
||||
22
database/seeds/SignerSeeder.php
Normal file
22
database/seeds/SignerSeeder.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SignerSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('signers')->insert([
|
||||
['name' => 'Nguyễn Thanh Toàn', 'description' => 'Trưởng phòng tài chính'],
|
||||
['name' => 'Đào Thị Xa', 'description' => 'Giám đốc sở'],
|
||||
['name' => 'Hoàng Công', 'description' => 'Giám đốc công ty MACD'],
|
||||
['name' => 'Nguyễn Công Quân', 'description' => null],
|
||||
['name' => 'Nguyễn Đức Tiên', 'description' => 'Phó giám đốc điều hành Hải Sơn'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
22
database/seeds/TitleSeeder.php
Normal file
22
database/seeds/TitleSeeder.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TitleSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('titles')->insert([
|
||||
['id' => 'GD', 'name' => 'Giám đốc'],
|
||||
['id' => 'PGD', 'name' => 'Phó giám đốc'],
|
||||
['id' => 'TP', 'name' => 'Trưởng phòng'],
|
||||
['id' => 'PP', 'name' => 'Phó phòng'],
|
||||
['id' => 'CV', 'name' => 'Chuyên viên'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
database/seeds/UserSeeder.php
Normal file
31
database/seeds/UserSeeder.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
[
|
||||
'id' => 'PKTCN-TP-1',
|
||||
'name' => 'Administrator',
|
||||
'email' => 'admin@domain.com',
|
||||
'password' => Hash::make('password'),
|
||||
'tel' => '0376111000',
|
||||
'birthday' => '1975-04-30',
|
||||
'department_id' => 'PKTCN',
|
||||
'title_id' => 'TP',
|
||||
'email_verified_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
factory(App\Entities\User::class, 300)->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user