2020-01-13 11:24:59 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Models\Auth\Permission;
|
|
|
|
use App\Models\Auth\Role;
|
|
|
|
use Faker\Generator as Faker;
|
|
|
|
|
|
|
|
$factory->define(Role::class, function (Faker $faker) {
|
|
|
|
$name = $faker->word;
|
|
|
|
|
|
|
|
return [
|
|
|
|
'name' => strtolower($name),
|
|
|
|
'display_name' => $name,
|
|
|
|
'description' => $name,
|
|
|
|
];
|
|
|
|
});
|
2020-01-13 11:40:30 +03:00
|
|
|
|
|
|
|
$factory->state(Role::class, 'permissions', function (Faker $faker) {
|
|
|
|
return [
|
|
|
|
'permissions' => Permission::take(50)->pluck('id')->toArray(),
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
$factory->afterCreating(Role::class, function ($role, $faker) {
|
|
|
|
$role->permissions()->attach(Permission::take(50)->pluck('id')->toArray());
|
|
|
|
});
|