Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

در ماگریشن اضافه کردن توضیحات به جدول تراکنشها به صورت مستقیم از نام جدول استفاده شده است که اشتباه است و باید از فایل کانفیگ خوانده شود #221

Open
farshadfahimi opened this issue Mar 5, 2020 · 0 comments

Comments

@farshadfahimi
Copy link

در حال حاضر اطلاعات درون ماگریشن به صورت زیر میباشد

<?php

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

class AddDescriptionToGatewayTransactions extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('gateway_transactions', function (Blueprint $table) {
            //
            $table->text('description')->after('ip')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('gateway_transactions', function (Blueprint $table) {
            //
            $table->dropColumn('description');

        });
    }
}

که باید تغییر کند و به صورت زیر ایجاد شود.
چون در زمان ماگریت امکان دارد کاربر نام جدول پیش فرض را تغییر داده باشد و با خطا مواجه میشود

<?php

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

class AddDescriptionToGatewayTransactions extends Migration
{
    function getTable()
    {
        return config('gateway.table','gateway_transactions');
    }

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table($this->getTable(), function (Blueprint $table) {
            $table->text('description')->after('ip')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table($this->getTable(), function (Blueprint $table) {
            //
            $table->dropColumn('description');

        });
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant