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

1 CREATE TABLE `group_resource` (<br />

2 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,<br />

3 `group_id` int(11) DEFAULT NULL,<br />

4 `resource_id` int(11) DEFAULT NULL,<br />

5 `created_at` datetime DEFAULT NULL,<br />

6 `updated_at` datetime DEFAULT NULL,<br />

7 `deleted_at` datetime DEFAULT NULL,<br />

8 PRIMARY KEY (`id`),<br />

9 KEY `group_resource_group_id_index` (`group_id`),<br />

10 KEY `group_resource_resource_id_index` (`resource_id`)<br />

11 ) ENGINE=InnoDB CHARSET=utf8;<br />

12<br />

13 CREATE TABLE `group_user` (<br />

14 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,<br />

15 `group_id` int(11) DEFAULT NULL,<br />

16 `user_id` int(11) DEFAULT NULL,<br />

17 `created_at` datetime DEFAULT NULL,<br />

18 `updated_at` datetime DEFAULT NULL,<br />

19 `deleted_at` datetime DEFAULT NULL,<br />

20 PRIMARY KEY (`id`),<br />

21 KEY `group_user_group_id_index` (`group_id`),<br />

22 KEY `group_user_user_id_index` (`user_id`)<br />

23 ) ENGINE=InnoDB CHARSET=utf8;<br />

Adding Views<br />

The views we need to create are those in which we will select which users and resources should be<br />

assigned to a group.<br />

1 <br />

2 @foreach ($resources as $resource)<br />

3 <br />

4 {{ Form::checkbox("resource_id[]", $resource->id, $group->resources->\<br />

5 contains($resource->id)) }}<br />

6 {{ $resource->name }}<br />

7 <br />

8 @endforeach<br />

9

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

Saved successfully!

Ooh no, something went wrong!