03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Access Control List 66<br />

Laravel 4 provides and excellent method for synchronising related database records — the sync()<br />

method. You simply provide it with the id(s) of the related records and it makes sure there is a<br />

record for each relationship. It couldn’t be easier!<br />

Finally, we will add a bit of CSS to make the lists less of a mess…<br />

1 .assign<br />

2 {<br />

3 padding : 10px 0 0 0;<br />

4 line-height : 22px;<br />

5 }<br />

6 .checkbox, .assign<br />

7 {<br />

8 float : left;<br />

9 clear : left;<br />

10 }<br />

11 .checkbox input[type='checkbox']<br />

12 {<br />

13 margin : 0 10px 0 0;<br />

14 float : none;<br />

15 }<br />

.<br />

This was extracted from public/css/layout.css.<br />

Take it for a spin! You will find that the related records are created (in the pivot) tables, and each<br />

time you submit it; the edit page will remember the correct relationships and show them back to<br />

you.<br />

Advanced Routes<br />

The final thing we need to do is manage how resources are translated into routes and how the<br />

security behaves in the presence of our simple ACL.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!