Added the ability to manage a group of users.

This commit is contained in:
2023-07-16 19:21:09 +06:00
parent ba7e52f8ac
commit 4083e2ec5e
45 changed files with 1173 additions and 10 deletions

View File

@@ -0,0 +1,62 @@
<?php declare(strict_types=1);
namespace App\View\Components\Private\Forms;
use App\Enums\Permission;
use App\Models\Role;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\View\View;
final class PermissionsForRole extends Form
{
public function __construct(
private readonly string $title,
private readonly string $name,
private readonly Role $role,
private readonly array $value
) { }
protected function getName(): string
{
return $this->name;
}
/**
* @return string
*/
private function getTitle(): string
{
return Str::ucfirst($this->title);
}
/**
* @return array
*/
private function getValue(): Collection
{
$value = old($this->getRequestName(), $this->value);
return collect($value);
}
/**
* @return Role
*/
private function getRole(): Role
{
return $this->role;
}
public function render(): View
{
return view('private.components.forms.permissions_for_role', [
'title' => $this->getTitle(),
'name' => $this->getName(),
'requestName' => $this->getRequestName(),
'permissions' => Permission::cases(),
'role' => $this->getRole(),
'value' => $this->getValue(),
]);
}
}