Attachment system some file
This commit is contained in:
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateMediableTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('media', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('disk', 32);
|
||||
$table->string('directory');
|
||||
$table->string('filename');
|
||||
$table->string('extension', 32);
|
||||
$table->string('mime_type', 128);
|
||||
$table->string('aggregate_type', 32);
|
||||
$table->integer('size')->unsigned();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['disk', 'directory']);
|
||||
$table->unique(['disk', 'directory', 'filename', 'extension']);
|
||||
$table->index('aggregate_type');
|
||||
});
|
||||
|
||||
Schema::create('mediables', function (Blueprint $table) {
|
||||
$table->integer('media_id')->unsigned();
|
||||
$table->string('mediable_type');
|
||||
$table->integer('mediable_id')->unsigned();
|
||||
$table->string('tag');
|
||||
$table->integer('order')->unsigned();
|
||||
|
||||
$table->primary(['media_id', 'mediable_type', 'mediable_id', 'tag']);
|
||||
$table->index(['mediable_id', 'mediable_type']);
|
||||
$table->index('tag');
|
||||
$table->index('order');
|
||||
$table->foreign('media_id')->references('id')->on('media')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('mediables');
|
||||
Schema::drop('media');
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ class Roles extends Seeder
|
||||
'auth-profile' => 'r,u',
|
||||
'companies-companies' => 'c,r,u,d',
|
||||
'common-import' => 'c',
|
||||
'common-uploads' => 'd',
|
||||
'items-items' => 'c,r,u,d',
|
||||
'incomes-invoices' => 'c,r,u,d',
|
||||
'incomes-revenues' => 'c,r,u,d',
|
||||
|
Reference in New Issue
Block a user