I have a tables user_id and event_id, every user can be added to every event, but how can I prevent that one user cannot be more times in the same event?
Example:
user_id event_id
3 1 -> ok
4 1 -> ok
3 1 -> not ok because the user is already added in line 1...
Is it to set in migration something?
Hi!
I guess you have to set multiple unique columns. You can do it with unique or primary property.
$table->unique(array('mytext', 'user_id'));
$table->primary(['first', 'second']);
Like they said here:
http://stackoverflow.com/questions/20065697/schema-builder-laravel-migrations-unique-on-two-columns
@ttimot24 fantastic laravel support, many thanks friend :)
$table->unique(array('mytext', 'user_id'));
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community