讨论数量:
目前找到两种解决办法
第一种:
Schema::create('books', function (Blueprint $table) {
$table->integer('reference');
});
DB::statement('ALTER TABLE books CHANGE reference reference INT(2) UNSIGNED ZEROFILL NOT NULL');
第二中:
function getOrderNoAttribute() {
return str_pad($this->id,4,'0',STR_PAD_LEFT);
}
目前找到两种解决办法
第一种:
第二中:
第一种是类似原生写法,第二种是查询获取的时候填充0;