修改用户信息时,在表单请求验证中排除当前邮箱所在的记录行,并检查邮箱的惟一性。php
5.2git
backend/user/{user}github
<?php namespace App\Http\Requests\Backend\User; use App\Http\Requests\Request; class UpdateRequest extends Request { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $id = $this->route('user'); //获取当前须要排除的id return [ 'email' => "required|email|unique:users,email,".$id, ]; } }
unique:表名,字段,须要排除的IDapp
欢迎加入技术讨论群 QQ : 339803849
个人开源博客 : https://github.com/moell-peng...ui