I am using Laravel 5.8 and attempting to set up a custom validation extension.
- I have created a class
GroupValidator
containing avalidate
function. - I have created a
ValidationServiceProvider
with the following code:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use App\Classes\GroupValidator;
class ValidationExtensionServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
Validator::extend('valid_parent_id', 'GroupValidator@validate');
}
}
When my validation triggers I get a Class GroupValidator does not exist
exception. However if I specify the full path to my class in the extend function call like so:
Validator::extend('valid_parent_id', 'App\Classes\GroupValidator@validate');
then everything works fine.
Is there some way I can set this up so that I don't have to include the full path to my class?
via Chebli Mohamed
1 commentaire:
PHP remove HTML and PHP tags from string
how to retrieve encrypted password from database in php
Text to speech in PHP
PHP get and set cookie
How to retrieve data from mongodb using php
PHP copying or moving a file
Enregistrer un commentaire