lundi 17 octobre 2016

Validation of type Request Laravel

Good friends greetings to all ...

I have a question and want to know if I can solve the Request validation method.

I have a table called condando and another called town.

In laravel I'm creating a view where once the chosen condando Select a drop-down should write the town, the idea is to associate localities with condandos.

Eg serious Dallas County town Texas in the United States.

So I'm working with the creation of the town, and as you know in laravel there is the option to create validations using the command:

 php artisan make:request nombredelrequest

I created my validations and so far I like this:

public function rules()
{
    return [
        'condado_id'=>'required',
        'nomb_localidad'=>'required'
        //
    ];
}
public function messages()
{
    return [
        'condado_id.required'=>'Necesitamos que elija un condado',
        'nomb_localidad.required'=>'Necesitamos el nombre de la localidad'
    ];

}

So far I'm telling you need to have the town and county, but I would somehow using this type of validation that if I try to register again the same town in the same county tell me it's not possible for already exists. Darce be the case that a town has a name exists in one county and another county a town with the same name that may be possible, I need to validate that if condando already exists in the area do not let me register.

I hope you can help me thank you very much ...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire