php - Limit one to many relationship to a custom maximum number in laravel 5 -


a hasmany(b) b belongsto(a) 

i want limit number of b maximum of 5.

1 row in can have maximum of 5 rows in b

is there way? or should use 1-1 relationship max 5 columns

here need do.

  1. count number of rows of b against given @ creation request.
  2. show error if more 5.

there no direct way limit b using laravel, far know.


Comments

Popular posts from this blog

javascript - How to diff two immutable objects -

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -

javascript - React.js: onClick function from child to parent -