SUKOHI / Agnomen by Sukohi

A PHP package mainly developed for Laravel to set attributes for error messages of when failing validation.
21
0
2
Package Data
Maintainer Username: Sukohi
Maintainer Contact: capilano.sukohi@gmail.com (Sukohi)
Package Create Date: 2015-08-20
Package Last Update: 2015-08-20
Language: PHP
License: Unknown
Last Refreshed: 2024-05-18 03:08:50
Package Statistics
Total Downloads: 21
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

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