sukohi/agnomen
Agnomen
A PHP package mainly developed for Laravel to set attributes for error messages of when failing validation.
Installation
Add this package name in composer.json
"require": {
"sukohi/agnomen": "1.*"
}
Execute composer command.
composer update
Usage
At first, add AgnomenTrait to App/Http/Requests/Request.php like this.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Sukohi\Agnomen\AgnomenTrait;
abstract class Request extends FormRequest
{
use AgnomenTrait;
private $attribute_names = [
'email' => 'YOUR-TEXT-1',
'password' => 'YOUR-TEXT-2',
'accepted' => 'YOUR-TEXT-3'
];
}
And make your own Request using the following command.
php artisan make:request *****Request
- see here for the details
then add your validation rules there like this.
public function rules()
{
return [
'email' => 'required',
'password' => 'required',
'accepted' => 'accepted'
];
}
Now if your application respond error messages, :attribute will be replaced with $attribute_names values.
See here for the details
e.g.)
The :attribute field is required. => The YOUR-TEXT-1 field is required.
License
This package is licensed under the MIT License.
Copyright 2015 Sukohi Kuhoh
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.