Last active
August 29, 2015 14:16
-
-
Save xaoc-303/3a8af73ef37a30e557f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Composer: "fzaninotto/faker": "v1.3.0" | |
| use Faker\Factory as Faker; | |
| class PermissionsTableSeeder extends Seeder { | |
| public function run() { | |
| $faker = Faker::create('de_DE'); | |
| foreach (['Owner', 'Admin', 'Moderator', 'Author', 'User'] as $role) { | |
| Role::create([ | |
| 'name' => $role | |
| ]); | |
| } | |
| foreach ([['read_site', 'Read Site'], ['read_own_profile', 'Read Own Profile'], ['write_own_profile', 'Write Own Profile'], ['read_other_profile', 'Read Other Profile'], ['write_other_profile', 'Write Other Profile']] as $perm) { | |
| Permission::create([ | |
| 'name' => $perm[0], | |
| 'display_name' => $perm[1], | |
| ]); | |
| } | |
| foreach ([[5, 1], [4, 3], [1, 5], [2, 4], [3, 3]] as $index) { | |
| Role::find($index[0])->perms()->save(Permission::find($index[1])); | |
| } | |
| foreach (range(1, 10) as $index) { | |
| User::find($index)->attachRole(Role::find($faker->numberBetween(1, 5))); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment