Laravel не может создать модель Eloquent - PullRequest
0 голосов
/ 06 июня 2018

Я не могу создать модель Eloquent в одном столбце.Редактировать существующую запись возможно.Ничто не будет зарегистрировано в laravel.log или php.log.так как 30 других моделей работают нормально, я не знаю, в чем здесь проблема.

Я уже пытался удалить

use Userstamps, SoftDeletes, Billable;

спасибо

<?php

namespace App;

use App\Traits\Userstamps;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laravel\Cashier\Billable;

class Company extends Model
{
    use Userstamps, SoftDeletes, Billable;
    protected $table = 'companies';

    protected $fillable = array(
        'name', 'stripe_id', 'card_brand', 'card_last_four', 'trial_ends_at', 'email', 'street', 'city', 'country', 'state', 'zip', 'fn', 'ln', 'phone'
    );
}

Контроллер

$company = \App\Company::created(array(
            'name' => 'test',
            'street' => '12',
            'city' => '12',
            'country' => '12',
            'state' => '12',
            'zip' => '12',
            'fn' => '12',
            'ln' => '12',
            'phone' => '12',
            'fax' => '12',
        ));

Миграция

Schema::create('companies', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->integer('updated_by')->unsigned()->nullable();
            $table->integer('created_by')->unsigned()->nullable();
            $table->integer('deleted_by')->unsigned()->nullable();
            $table->timestamps();
            $table->softDeletes();
            $table->string('stripe_id')->nullable();
            $table->string('card_brand')->nullable();
            $table->string('card_last_four')->nullable();
            $table->timestamp('trial_ends_at')->nullable();
            $table->string('email');
            $table->string('street');
            $table->string('city');
            $table->string('country');
            $table->string('state')->nullable();
            $table->string('zip');
            $table->string('fn')->nullable();
            $table->string('ln')->nullable();
            $table->string('phone')->nullable();
            $table->string('fax')->nullable();
        });

1 Ответ

0 голосов
/ 06 июня 2018

Ваше $fillable свойство установлено неправильно.Например, вам не хватает fax.Убедитесь, что каждый столбец, который вы хотите сделать доступным для массового назначения, задан в массиве $fillable.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...