jeudi 29 décembre 2016

How to set unique for specific filed from specific table?

I have this where i have all features from database:

$features = Feature::all();

User can add new additional feature that will be added in this table, but i want to validate so if user enter something that is already in databse to get a message. So name need to be unique. Any suggestion how can i do that?

I tried this but it save it anyway.

 $this->validate($request, [
        'name' => 'unique:features',
    ]);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire