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',
    ]);



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2il8wLl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire