03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Access Control List 61<br />

.<br />

This file should be saved as app/views/resource/assign.blade.php.<br />

1 <br />

2 @foreach ($users as $user)<br />

3 <br />

4 {{ Form::checkbox("user_id[]", $user->id, $group->users->contains($us\<br />

5 er->id)) }}<br />

6 {{ $user->username }}<br />

7 <br />

8 @endforeach<br />

9 <br />

.<br />

This file should be saved as app/views/user/assign.blade.php.<br />

These views similarly iterate over resources and users (passed to the group edit view) and render<br />

markup for checkboxes. It’s important to note the names of the checkbox inputs ending in [] — this<br />

is the recommended way to passing array-like data in HTML forms.<br />

The first parameter of the Form::checkbox() method is the input’s name. The second is its value.<br />

The third is whether of not the checkbox should initially be checked. Eloquent models provide a<br />

useful contains() method which searches the related rows for those matching the provided id(s).<br />

1 @extends("layout")<br />

2 @section("content")<br />

3 {{ Form::open([<br />

4 "url" => URL::full(),<br />

5 "autocomplete" => "off"<br />

6 ]) }}<br />

7 {{ Form::field([<br />

8 "name" => "name",<br />

9 "label" => "Name",<br />

10 "form" => $form,<br />

11 "placeholder" => "new group",<br />

12 "value" => $group->name<br />

13 ])}}<br />

14 @include("user/assign")<br />

15 @include("resource/assign")

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

Saved successfully!

Ooh no, something went wrong!