[WIP] Refactor project
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kalnoy\Nestedset\NestedSet;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCategoriesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.categories.tables.categories'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->increments('id');
|
||||
$table->string('slug');
|
||||
$table->json('name');
|
||||
$table->json('description')->nullable();
|
||||
NestedSet::columns($table);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// Indexes
|
||||
$table->unique('slug');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.categories.tables.categories'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCategorizablesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.categories.tables.categorizables'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->integer('category_id')->unsigned();
|
||||
$table->morphs('categorizable');
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->unique(['category_id', 'categorizable_id', 'categorizable_type'], 'categorizables_ids_type_unique');
|
||||
$table->foreign('category_id')->references('id')->on(config('rinvex.categories.tables.categories'))
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.categories.tables.categorizables'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTagsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.tags.tables.tags'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->increments('id');
|
||||
$table->string('slug');
|
||||
$table->json('name');
|
||||
$table->json('description')->nullable();
|
||||
$table->mediumInteger('sort_order')->unsigned()->default(0);
|
||||
$table->string('group')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// Indexes
|
||||
$table->unique('slug');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.tags.tables.tags'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTaggablesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.tags.tables.taggables'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->integer('tag_id')->unsigned();
|
||||
$table->morphs('taggable');
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->unique(['tag_id', 'taggable_id', 'taggable_type'], 'taggables_ids_type_unique');
|
||||
$table->foreign('tag_id')->references('id')->on(config('rinvex.tags.tables.tags'))
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.tags.tables.taggables'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user