本文整理汇总了PHP中Validator::resolver方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::resolver方法的具体用法?PHP Validator::resolver怎么用?PHP Validator::resolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::resolver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
protected function validate($data, $rules)
{
\Validator::resolver(function ($translator, $data, $rules, $messages, $parameters) {
return new BidValidator($translator, $data, $rules, $messages, $parameters);
});
parent::validate($data, $rules);
}
示例2: validate
protected function validate($data, $rules)
{
\Validator::resolver(function ($translator, $data, $rules, $messages, $parameters) {
return new NumberValidator($translator, $data, $rules, $messages, $parameters);
});
parent::validate($data, $this->getRules($data));
}
示例3: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
Validator::resolver(function ($translator, $data, $rules, $messages) {
return new Validation($translator, $data, $rules, $messages);
});
}
示例4: validate
protected function validate($data, $rules)
{
\Validator::resolver(function ($translator, $data, $rules, $messages, $parameters) {
$class = $this->validatorClass;
/** @var ZidishaValidator $validator */
$validator = new $class($translator, $data, $rules, $messages, $parameters);
$validator->setForm($this);
return $validator;
});
$this->validator = \Validator::make($data, $rules);
}
示例5: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('xjtuwangke/laravel-kform');
\Validator::resolver(function ($translator, $data, $rules, $messages) {
return new KValidator($translator, $data, $rules, $messages);
});
}
示例6: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('xjtuwangke/laravel-cms', 'laravel-cms');
\Validator::resolver(function ($translator, $data, $rules, $messages) {
return new KValidator($translator, $data, $rules, $messages);
});
include __DIR__ . '/../../routes.php';
}
示例7: boot
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'Kaamaru\\Forums');
\Validator::resolver(function ($translator, $data, $rules, $messages) {
return new ValidationRules($translator, $data, $rules, $messages);
});
\Auth::extend('eloquent', function ($app) {
$model = $this->app['config']['auth.model'];
return new EloquentUserProvider($this->app['hash'], $model);
});
require __DIR__ . '/Http/breadcrumbs.php';
}
示例8: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\HTML::macro('activeClass', function ($path, $active = 'active') {
if (Request::is($path . "*")) {
return $active;
}
return '';
});
\Validator::resolver(function ($translator, $data, $rules, $messages) {
return new CustomValidator($translator, $data, $rules, $messages);
});
\Blade::extend(function ($value) {
return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
});
}
示例9: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
\Validator::resolver(function ($translator, $data, $rules, $messages) {
return new RestValidator($translator, $data, $rules, $messages);
});
\Validator::extend('idarray', function ($attr, $value, $params) {
if (!is_array($value)) {
return false;
}
foreach ($value as $v) {
if (!is_int($v) || (int) $v < 1) {
return false;
}
}
return true;
});
}
示例10: mysqli_query
}
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';') {
// Perform the query
mysqli_query($db_conn, $templine) or print 'Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />';
// Reset temp variable to empty
$templine = '';
}
}
//echo "Tables imported successfully";
}
function generate_mail_config($host, $mail_driver, $email_name, $email_address)
{
return "<?php\n\nreturn array(\n\n /*\n |--------------------------------------------------------------------------\n | Mail Driver\n |--------------------------------------------------------------------------\n |\n | Laravel supports both SMTP and PHP's 'mail' function as drivers for the\n | sending of e-mail. You may specify which one you're using throughout\n | your application here. By default, Laravel is setup for SMTP mail.\n |\n | Supported: 'smtp', 'mail', 'sendmail', 'mailgun', 'mandrill', 'log'\n |\n */\n\n 'driver' => '{$mail_driver}',\n\n /*\n |--------------------------------------------------------------------------\n | SMTP Host Address\n |--------------------------------------------------------------------------\n |\n | Here you may provide the host address of the SMTP server used by your\n | applications. A default option is provided that is compatible with\n | the Mailgun mail service which will provide reliable deliveries.\n |\n */\n\n 'host' => '{$host}',\n\n /*\n |--------------------------------------------------------------------------\n | SMTP Host Port\n |--------------------------------------------------------------------------\n |\n | This is the SMTP port used by your application to deliver e-mails to\n | users of the application. Like the host we have set this value to\n | stay compatible with the Mailgun e-mail application by default.\n |\n */\n\n 'port' => 587,\n\n /*\n |--------------------------------------------------------------------------\n | Global 'From' Address\n |--------------------------------------------------------------------------\n |\n | You may wish for all e-mails sent by your application to be sent from\n | the same address. Here, you may specify a name and address that is\n | used globally for all e-mails that are sent by your application.\n |\n */\n\n 'from' => array('address' => '{$email_address}', 'name' => '{$email_name}'),\n\n /*\n |--------------------------------------------------------------------------\n | E-Mail Encryption Protocol\n |--------------------------------------------------------------------------\n |\n | Here you may specify the encryption protocol that should be used when\n | the application send e-mail messages. A sensible default using the\n | transport layer security protocol should provide great security.\n |\n */\n\n 'encryption' => 'tls',\n\n /*\n |--------------------------------------------------------------------------\n | SMTP Server Username\n |--------------------------------------------------------------------------\n |\n | If your SMTP server requires a username for authentication, you should\n | set it here. This will get used to authenticate with your server on\n | connection. You may also set the 'password' value below this one.\n |\n */\n\n 'username' => null,\n\n /*\n |--------------------------------------------------------------------------\n | SMTP Server Password\n |--------------------------------------------------------------------------\n |\n | Here you may set the password required by your SMTP server to send out\n | messages from your application. This will be given to the server on\n | connection so that the application will be able to send messages.\n |\n */\n\n 'password' => null,\n\n /*\n |--------------------------------------------------------------------------\n | Sendmail System Path\n |--------------------------------------------------------------------------\n |\n | When using the 'sendmail' driver to send e-mails, we will need to know\n | the path to where Sendmail lives on this server. A default path has\n | been provided here, which will work well on most of your systems.\n |\n */\n\n 'sendmail' => '/usr/sbin/sendmail -bs',\n\n /*\n |--------------------------------------------------------------------------\n | Mail 'Pretend'\n |--------------------------------------------------------------------------\n |\n | When this option is enabled, e-mail will not actually be sent over the\n | web and will instead be written to your application's logs files so\n | you may inspect the message. This is great for local development.\n |\n */\n\n 'pretend' => false,\n\n);\n";
}
function generate_services_config($mandrill_secret, $mandrill_username)
{
return "<?php\n\nreturn array(\n\n /*\n |--------------------------------------------------------------------------\n | Third Party Services\n |--------------------------------------------------------------------------\n |\n | This file is for storing the credentials for third party services such\n | as Stripe, Mailgun, Mandrill, and others. This file provides a sane\n | default location for this type of information, allowing packages\n | to have a conventional place to find your various credentials.\n |\n */\n\n 'mailgun' => array(\n 'domain' => '',\n 'secret' => '',\n ),\n\n 'mandrill' => array(\n 'secret' => '{$mandrill_secret}',\n 'username' => '{$mandrill_username}',\n ),\n\n 'stripe' => array(\n 'model' => 'User',\n 'secret' => '',\n ),\n\n);\n";
}
class PhoneValidationRule extends \Illuminate\Validation\Validator
{
public function validatePhone($attribute, $value, $parameters)
{
return preg_match("/^([0-9\\+]*)\$/", $value);
}
}
Validator::resolver(function ($translator, $data, $rules, $messages) {
return new PhoneValidationRule($translator, $data, $rules, $messages);
});
示例11: app_path
| In addition to using Composer, you may use the Laravel class loader to
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/**
* New relic App
*/
Newrelic::setAppName(Config::get('laravel-newrelic::app_name'));
/**
* Custom validator
*/
// Register Api key validator
Validator::resolver(function ($translator, $data, $rules, $messages) {
return new CustomValidator($translator, $data, $rules, $messages);
});
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a rotating log file setup which creates a new file each day.
|
*/
$logFile = 'log-' . php_sapi_name() . '.txt';
Log::useDailyFiles(storage_path() . '/logs/' . $logFile);
/*
|--------------------------------------------------------------------------
示例12: NABValidator
<?php
use NAB\Validator\Validator as NABValidator;
Validator::resolver(function ($translator, $data, $rules, $messages) {
$messages['id'] = "Invalid ID";
return new NABValidator($translator, $data, $rules, $messages);
});
示例13: app_path
Log::error($exception);
});
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenance mode is in effect for the application.
|
*/
App::down(function () {
return Response::make("Be right back!", 503);
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/observables.php';
require app_path() . '/filters.php';
$app['Cartalyst\\Sentry\\Sentry'] = $app['sentry'];
Validator::resolver(function ($translator, $data, $rules, $messages) {
return new \Faxbox\Service\Validation\CustomLaravelValidator($translator, $data, $rules, $messages);
});
示例14: registerValidator
/**
*
*/
protected function registerValidator()
{
\Validator::resolver(function ($translator, $data, $rules, $messages, $customAttributes) {
return new Validator($translator, $data, $rules, $messages, $customAttributes);
});
}
示例15: function
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
use Illuminate\Support\Str;
use Carbon\Carbon;
// Ensure that the custom validation rules are registered so the factories also
// have them available.
Validator::resolver(function ($translator, $data, $rules, $messages) {
return new \App\Services\SpiraValidator($translator, $data, $rules, $messages);
});
$factory->define(App\Models\TestEntity::class, function ($faker) {
return ['entity_id' => $faker->uuid, 'varchar' => $faker->word, 'hash' => Hash::make($faker->word), 'integer' => $faker->numberBetween(0, 500), 'decimal' => $faker->randomFloat(2, 0, 100), 'boolean' => $faker->boolean(), 'nullable' => null, 'text' => $faker->paragraph(3), 'date' => $faker->date(), 'multi_word_column_title' => true, 'hidden' => $faker->boolean()];
});
$factory->defineAs(App\Models\TestEntity::class, 'custom', function ($faker) use($factory) {
$testEntity = $factory->raw(App\Models\TestEntity::class);
return array_merge($testEntity, ['varchar' => 'custom']);
});
$factory->define(App\Models\User::class, function ($faker) {
return ['user_id' => $faker->uuid, 'username' => $faker->unique()->userName, 'email' => $faker->unique()->email, 'email_confirmed' => $faker->optional(0.9)->dateTimeThisYear(), 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'country' => $faker->randomElement(['AU', 'BE', 'DE', 'NZ', 'US']), 'timezone_identifier' => $faker->timezone, 'avatar_img_url' => $faker->optional(0.8)->imageUrl(500, 500, 'people'), 'user_type' => $faker->randomElement(App\Models\User::$userTypes)];
});
$factory->define(App\Models\UserProfile::class, function ($faker) {
return ['phone' => $faker->optional(0.5)->phoneNumber, 'mobile' => $faker->optional(0.5)->phoneNumber, 'dob' => $faker->dateTimeThisCentury()->format('Y-m-d'), 'gender' => $faker->optional(0.5)->randomElement(['M', 'F', 'N/A']), 'about' => $faker->optional(0.5)->text(120), 'facebook' => $faker->boolean() ? substr($faker->url(), 0, 100) : null, 'twitter' => $faker->boolean() ? '@' . $faker->userName() : null, 'pinterest' => $faker->boolean() ? substr($faker->url(), 0, 100) : null, 'instagram' => $faker->boolean() ? substr($faker->url(), 0, 100) : null, 'website' => $faker->boolean() ? substr($faker->url(), 0, 100) : null];
});
$factory->defineAs(App\Models\User::class, 'admin', function ($faker) use($factory) {