1
votes

I'm just trying to implement a simple validation using Laravel Validator Facade. But it keeps giving me this error below:

Fatal error: Call to undefined method Illuminate\Support\Facades\Validator::make() in C:\xampp\htdocs..\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 221

This is my code below:

use Validator;

/**
 * Validate the tenant's credentials
 *
 * @param array $data
 * @return bool
 */
public function validate(array $data)
{
    $data = array_only($data, ['email', 'href']);

    $validator = Validator::make($data, $this->rules);

    if ($validator->passes()) return true;

    $this->errors = $validator->messages();

    return false;
}
3
Try adding a back slash to the Facade namespace use \ValidatorMatt Wohler
I did. It still shows the same error. I don't know what I'm doing wrong. I have searched using google before finally posting here. Any more idea on what I could do?geebengs
try: use Illuminate\Support\Facades\Validatordparoli
i have tried that but still showing same error. Any more ideas on what to do please?geebengs
Would you be able to show your rules array as well?Rwd

3 Answers

3
votes

use this at the top of your script instead of the long namespaced Facade

use Validator;

and everything should be fine

0
votes

Check if 'Illuminate\Validation\ValidationServiceProvider' is available or not in this file
app/config/app.php If not then add this line 'Validator' => Illuminate\Support\Facades\Validator::class,

0
votes

If all else fails, you should try re-building the Laravel app by deleting the vendor/ directory and running composer install.