primo upload

This commit is contained in:
claus75a
2024-03-16 20:37:32 +01:00
commit e43b9b4b28
3019 changed files with 406000 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Tests\Setup;
use Vanguard\Permission;
use Vanguard\Role;
class RoleFactory
{
protected $permissions = [];
protected $removable = false;
public function withPermissions($permissions)
{
$this->permissions = func_get_args();
return $this;
}
public function removable()
{
$this->removable = true;
return $this;
}
public function unremovable()
{
$this->removable = false;
return $this;
}
public function create()
{
$role = Role::factory()->create([
'removable' => $this->removable
]);
foreach ($this->permissions as $name) {
$role->attachPermission(Permission::where('name', $name)->first());
}
return $role;
}
}