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 54<br />

1 (function($){<br />

2 $(".confirm").on("click", function() {<br />

3 return confirm($(this).data("confirm"));<br />

4 });<br />

5 }(jQuery));<br />

.<br />

This file should be saved as public/js/layout.js.<br />

1 @section("footer")<br />

2 @parent<br />

3 <br />

4 <br />

5 @stop<br />

.<br />

This was extracted from app/views/group/index.blade.php.<br />

You’ll notice I have linked to jquery.js (any recent version will do). The code in layout.js adds a<br />

click event handler on to every element with class=”confirm” to prompt the user with the message<br />

in data-confirm=”…”. If “OK” is clicked; the callback returns true and the browser will redirect to<br />

the page on the other end (in this case the deleteAction() method on our GroupController class).<br />

Otherwise the click will be ignored.<br />

Adding Users And Resources<br />

Next on our list is making a way for us to specify resource information and add users to our groups.<br />

Both of these thing will happen on the group edit page; but before we get there we will need to deal<br />

with migrations, models and relationships…<br />

Adding Migrations, Models And Relationships

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

Saved successfully!

Ooh no, something went wrong!