CodepadME / laravel-tricks

The source code for the Laravel Tricks website
http://laravel-tricks.com
MIT License
967 stars 297 forks source link

Unique category slug #22

Open cojocaru opened 10 years ago

cojocaru commented 10 years ago

Hi,

When I try to save a category with the same name , because the slug has to be unique I get an Illuminate \ Database \ QueryException .

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'aaa' for key 'categories_slug_unique' (SQL: insert into categories (name, slug, description, order, updated_at, created_at) values (aaa, aaa, aaaa, 4, 2014-03-09 19:57:16, 2014-03-09 19:57:16))

I will try to fix this in one fork soon, so if it will not be fixed meanwhile will propose a pull request, thx.

stidges commented 10 years ago

Could you tell me the use case for having the same category twice? I can't think of a reason why you would want to have that :)

dabernathy89 commented 10 years ago

@stidges I think @cojocaru just means the exception should be caught

stidges commented 10 years ago

Oh of course... Sorry about that, thanks for the clarification :)

cojocaru commented 10 years ago

@dabernathy89, @stidges yep, this was what I meant, of course you never need the same name , esp for categories.