0
我做得不對的驗證Laravel 5.4 - 驗證工作不
<?php
namespace App\Http\Controllers\Auth;
use Validator;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class SignupController extends Controller
{
public function postSignup(Request $request)
{
if($this->validate($request, [
'first_name' => 'required|max:255'
])){
echo json_encode(array('TRUE'));
}else{
echo json_encode(array('FALSE'));
}
}
}
請求數據是正確的...
但始終驗證返回null ......和返回JSON是FALSE
退房如何從[Laravel驗證]寫Laravel驗證(https://laravel.com/docs/5.4/validation#manually-creating-validators) –
'validate'不返回true或false。它在失敗時拋出異常,如果成功則返回任何內容。 – apokryfos