Laravel无法创建Eloquent模型

时间:2018-06-06 13:20:55

标签: php laravel eloquent

我无法在一列上创建一个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 :(得分:0)

您的$fillable属性设置错误。例如,您错过了fax。确保要为质量分配提供的每个列都设置在$fillable数组中。