Php Laravel 5.6 PostGres Json默认值为空

Php Laravel 5.6 PostGres Json默认值为空,php,laravel,postgresql,Php,Laravel,Postgresql,我一次只需要插入1个JSON数组,因此如果没有条目,JSON数组需要默认为null。我有办法做到这一点吗 采用以下方法: 我的迁移是 Schema::create('job_details', function (Blueprint $table) { $table->integer('id')->default('0'); $table->primary('id'); $table->foreign('id')->references('i

我一次只需要插入1个JSON数组,因此如果没有条目,JSON数组需要默认为null。我有办法做到这一点吗

采用以下方法:

我的迁移是

Schema::create('job_details', function (Blueprint $table) {
    $table->integer('id')->default('0');
    $table->primary('id');
    $table->foreign('id')->references('id')->on('job_searches');
    $table->json('Location_of_job');
    $table->json('API_URL'); 
    $table->json('Redirected_URL'); 
    $table->json('Description'); 
    $table->json('Salary',6,2); 
    $table->timestamps();
});
型号:

protected $primaryKey = 'id';
public $timestamps = true;

protected $fillable = ['API_URL', 'Redirected_URL','Location_of_job','Description','Salary',];

protected $casts = [
    'Location_of_job' => 'array',
    'API_URL' => 'array',
    'Redirected_URL' => 'array',
    'Description' => 'array',
    'Salary' => 'array'
];
protected $attributes = array(
    'json' => '{}'
);
获取以下内容时出错:

SQLSTATE[23502]:非空冲突:7错误:列中的值为空 “作业的位置”违反非空约束详细信息:行失败 包含(0,null,null,null,null,null,null,null,null,null)。(SQL:insert 进入“作业详细信息”(“API URL”)值(),(),(),(),(),(),(),(),(),(),(),(),(), (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),())

发件人:

要使列“可为空”,可以使用
nullable
方法


我以前使用过它,它没有将它们设置为“null”(事实上,它只对时间戳有效)。不完全确定它是否工作,因为我定义了“json={}”,但非常感谢!
$table->json('Location_of_job')->nullable();
$table->json('API_URL')->nullable(); 
$table->json('Redirected_URL')->nullable(); 
$table->json('Description')->nullable(); 
$table->json('Salary', 6, 2)->nullable();