如何解决Laravel迁移类型年变为未定义方法
我在laravel 5.8上的迁移存在问题。我打算按照文档中的说明制作Year Column。但是我继续收到此错误“ [Symfony \ Component \ Debug \ Exception \ FatalThrowableError]调用未定义的方法Illuminate \ Database \ Schema \ Blueprint :: year()”。
这是我的迁移文件:
Schema::create('pengajuan_arsip',function(Blueprint $table) {
$table->increments('id');
$table->uuid('uuid');
$table->integer('id_pegawai_pengaju');
$table->string('nip_pengaju',50);
$table->string('nik_pengaju',50);
$table->string('nama_pengaju',200);
$table->string('bidang',100);
$table->string('sub_bidang',100);
$table->string('tingkat',50);
$table->integer('status');
$table->boolean('is_setuju');
$table->integer('setuju_kasi_by');
$table->year('tahun_mulai');
$table->year('tahun_akhir');
$table->timestamps();
$table->softDeletes();
});
Schema::create('detail_histori_arsip',function(Blueprint $table) {
$table->increments('id');
$table->uuid('uuid');
$table->integer('id_pengajuan_arsip');
$table->integer('status');
$table->integer('status_by');
$table->integer('diambil_by');
$table->date('tanggal_diambil');
$table->integer('id_ruang_arsip');
$table->date('tanggal_pindah');
$table->timestamps();
});
Schema::create('detail_arsip',function(Blueprint $table) {
$table->increments('id');
$table->uuid('uuid');
$table->integer('id_pengajuan_arsip');
$table->string('nama_dokumen',200);
$table->year('tahun_dokumen');
$table->timestamps();
});
解决方法
我建议改用无符号小整数。对于年份值,没有什么真正值得注意的事情需要它自己的特殊数据库列类型:
$table->unsignedSmallInteger('tahun_mulai');
$table->unsignedSmallInteger('tahun_akhir');
这将使您可以将值从0
保存到65535
。
如果出于任何原因需要卑诗省用负数表示的时间,然后尝试使用带符号的小整数:
$table->smallInteger('tahun_mulai');
$table->smallInteger('tahun_akhir');
这将使您可以将值从-32768
保存到32767
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。