sukohi / agnomen
A PHP package mainly developed for Laravel to set attributes for error messages of when failing validation.
Requires
- laravel/framework: ~5.0
This package is not auto-updated.
Last update: 2024-11-09 19:32:27 UTC
README
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