我跑
php artisan make:model Models/Test -m
创建迁移文件
Schema::create('tests', function (Blueprint $table) {
$table->bigIncrements('id');
$table->double('longitude', 9, 4);
$table->timestamps();
});
运行迁移和编辑模型
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Test extends Model
{
protected $fillable = ['longitude'];
//
}
当我跑步时
$marker = Test::firstOrCreate([
'longitude' => floatval(19.9276),
]);
echo $marker->id;
我一直看到新条目添加到 db 中。
当我将列类型更改为 varchar 问题时不会发生。