faker->word; return [ 'name' => strtolower($name), 'display_name' => $name, 'description' => $name, ]; } /** * Indicate the model permissions. * * @return \Illuminate\Database\Eloquent\Factories\Factory */ public function permissions() { return $this->state(function (array $attributes) { return [ 'permissions' => $this->getPermissions(), ]; }); } protected function getPermissions() { return Permission::take(50)->pluck('id')->toArray(); } /** * Configure the model factory. * * @return $this */ public function configure() { return $this->afterCreating(function (Model $role) { $role->permissions()->attach($this->getPermissions()); }); } }