pipe-dream / laravel-create

Create Laravel projects really fast
1.31k stars 109 forks source link

Add validator files #30

Closed zarpelon closed 5 years ago

zarpelon commented 5 years ago

Also add the validator files that will be inside app/Http/Requests

An example would be:

Car id name => required|min:3|max:255

And we would have a CarRequest.php file more or less like this:

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CarRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|min:3|max:255'
        ];
    }

    /**
     * Mensagens caso pare nos rules atribuidos
     * @return array
     */
    public function messages() {
        return [
            'name.required' => 'The :attribute is required',
            'name.min' => 'The :attribute ... :min',        
            'name.max' => 'The :attribute .... :max',
        ];
    }
}
ajthinking commented 5 years ago

Thanks @zarpelon, added this to the trello board

ajthinking commented 5 years ago

Thanks @zarpelon ! This is queued in next version, closing for now.