MySqlBuilder :: defaultStringLength () - PullRequest
       36

MySqlBuilder :: defaultStringLength ()

0 голосов
/ 24 октября 2018

У меня проблема defaultStringLength (), несмотря на несколько попыток.Я объясню вам мою процедуру.

В базе данных файловой папки -> 2018_10_24_103651_create_devis_table.php У меня есть что:

<?php

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

class CreateDevisTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('devis', function (Blueprint $table) {
            $table->increments('id');
            $table->string('firstname');
            $table->string('lastname');
            $table->string('email');
            $table->string('phone');
            $table->string('start_adress');
            $table->string('end_adress');
            $table->text('remarks');
            $table->timestamps();
        });
    }

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

Затем я должен изменить файл AppServiceProvider.php

Вот моя модификация

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(255);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

После того, как я запускаю команду next php artisan migrate и у меня появляется похожее сообщение об ошибке -> вызов неопределенного метода Illuminate \ Database \ Schema \ MySqlBuilder :: defaultStringLength ()

У вас есть идея, пожалуйста?Заранее благодарю за ответы.

1 Ответ

0 голосов
/ 24 октября 2018

defaultStringLength это введено в Laravel 5.4

Вы можете обновить версию Laravel

или

Вы указываете длину как $table->string('coumname', 255); Вы не можете указать больше, чем 255

...