bug描述
laravel获取接口参数,传递的是空字符串''
,接收到的却是null
,导致数据库异常
解决
取消中间件 ConvertEmptyStringsToNull
app/Http/Kernel.php
<?php class Kernel extends HttpKernel { protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, // bug: 空字符串转为了null // \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ];