last day (15 days later) » 

9:06 PM
1
A: Laravel checking if name is already in use throws error

OhgodwhyThe validator automatically handles this for you: $validate = Validator:make(array( .... 'name' => 'unique:users,name' )); This will produce the correct error when the name already exists in the table users on the column name. You can customize the error message if that's something you...

 
Where to place this code ?
 
@feknez Prior to your $validator->fails() check.
 
Class 'Illuminate\Foundation\Auth\Validator' not found I get this. Should I include Validator ?
 
@feknaz That's correct
 
So I included use Illuminate\Foundation\Auth\Validator; and I still get Illuminate\Foundation\Auth\Validator not found
 
9:06 PM
@feknaz where are you using this code?
 
RegistersUsers.php
 
@feknaz And does RegistersUsers.php extend Controller ?
 
No, it doesn't extend a controller
 
I need to see the structure of the file & the code
 
Hi, I included it now like this: use Validator;
And I get the error like this: Argument 2 passed to Illuminate\Validation\Factory::make() must be of the type array, none given, called in
 
9:09 PM
Sorry. The first argument should be all the inputs to validate against.
$inputs = Input::all()
Validator::Make($inputs, array(....));
 
I still get
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'feknaz' for key 'name'
 
And you've used that code prior to if($validator->fails()) ?
 
Do you know whats the problem ?
Are you there ?
 

last day (15 days later) »