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

.<br />

This file should be saved as app/database/migrations/0000_00_00_000000_CreateGroupTable.php.<br />

Yours may be slightly different as the 0’s are replaced with other numbers.<br />

The group table has a primary key, timestamp fields (including created_at, updated_at and<br />

deleted_at) as well as a name field.<br />

If you’re skipping migrations; the following SQL should create the same table structure as the<br />

migration:<br />

1 CREATE TABLE `group` (<br />

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

3 `name` varchar(255) DEFAULT NULL,<br />

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

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

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

7 PRIMARY KEY (`id`)<br />

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

Listing Groups<br />

We’re going to be creating views to manage group records; more comprehensive than those we<br />

created for users previously, but much the same in terms of complexity.<br />

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

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

3 @if (count($groups))<br />

4 <br />

5 <br />

6 name<br />

7 <br />

8 @foreach ($groups as $group)<br />

9 <br />

10 {{ $group->name }}<br />

11 <br />

12 @endforeach<br />

13 <br />

14 @else<br />

15 There are no groups.<br />

16 @endif<br />

17 add group<br />

18 @stop

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

Saved successfully!

Ooh no, something went wrong!