%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/news/database/migrations/
Upload File :
Create Path :
Current File : /var/www/html/news/database/migrations/2017_04_02_110000_create_media_table.php

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMediaTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('media', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('mediable_id'); // article_id, user_id, category_id, reference_id
            $table->string('mediable_type'); // reference_type: User, Article, Category
            $table->index(['mediable_id', 'mediable_type']);
            $table->string('file_name')->unique();
            $table->string('real_file_name');
            $table->unsignedBigInteger('uploader_id')->unsigned();
            $table->foreign('uploader_id')->references('id')->on('users');
            $table->enum('media_type', [
                App\Models\Media::MEDIA_TYPE_IMAGE_PROFILE,
                App\Models\Media::MEDIA_TYPE_IMAGE_FEATURE,
                App\Models\Media::MEDIA_TYPE_IMAGE_SLIDER,
                App\Models\Media::MEDIA_TYPE_VIDEO,
                App\Models\Media::MEDIA_TYPE_IMAGE_CATEGORY,
                App\Models\Media::MEDIA_TYPE_IMAGE_LOGO,
                App\Models\Media::MEDIA_TYPE_IMAGE_FAVICON
            ]);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('media');
    }
}

Zerion Mini Shell 1.0