[WIP] Refactor project

This commit is contained in:
Ludovic CANDELLIER
2021-05-21 00:21:05 +02:00
parent 4ce0fa942d
commit b50f50ea62
347 changed files with 14104 additions and 1608 deletions

View File

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

View File

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