I've got problem with my laravel I can't post the data
One error says
InvalidArgumentException in Validator.php line 2593:
Validation rule unique requires at least 1 parameters.
And here it's my code
public function postUbah(Request $request, $id)
$validator = Validator::make($request->all(), [
'username' => 'required|unique:user|min:5',
'name' => 'required',
'group' => 'required'
]);
}
Thanks for the help.
Here it's my model
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
protected $table = 'user';
protected $fillable = ['username', 'password'];
protected $hidden = ['password', 'remember_token'];
You've forgot to add the parameter in validation rule to specify the database table column which should be unique in validation rule. You can do it like,
$validator = Validator::make($request->all(), [
'username' => 'required|unique:user,name|min:5',
'name' => 'required',
'group' => 'required'
]);
Why dont you just use like this
L5.5
public function postUbah(Request $request, $id)
$validator = $request->validate([
'username' => 'required|unique:user|min:5',
'name' => 'required',
'group' => 'required'
]);
}
L5.4
public function postUbah(Request $request, $id)
$validator = $this->validate($request, [
'username' => 'required|unique:user|min:5',
'name' => 'required',
'group' => 'required'
]);
}
Im aware that your table name is user
.. make sure your User Model have
class User {
protected $table = "user";
}
Use "unique:users" instead of "unique:user". This can work for some cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With