2024-08-30 02:17:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2024-08-30 09:14:48 +02:00
|
|
|
use App\Facade\Filters\Filters;
|
2024-08-30 02:17:13 +02:00
|
|
|
use App\Http\Requests\AuthorizedRequest;
|
2024-08-30 03:31:22 +02:00
|
|
|
use App\Http\Requests\UserEditRequest;
|
2024-08-30 02:17:13 +02:00
|
|
|
use App\Services\UserService;
|
|
|
|
|
|
|
|
class PrivateUserController extends Controller
|
|
|
|
{
|
|
|
|
public function __construct(
|
|
|
|
private UserService $userService
|
|
|
|
) { }
|
|
|
|
|
|
|
|
public function list(AuthorizedRequest $request)
|
|
|
|
{
|
|
|
|
return $this->userService->listAll();
|
|
|
|
}
|
|
|
|
|
2024-08-30 09:14:48 +02:00
|
|
|
public function listFilters(AuthorizedRequest $request)
|
|
|
|
{
|
|
|
|
$filters = Filters::fromArrayOrObject($request->all());
|
|
|
|
return $this->userService->listAll($filters);
|
|
|
|
}
|
|
|
|
|
2024-08-30 02:17:13 +02:00
|
|
|
public function get(AuthorizedRequest $request, string $id)
|
|
|
|
{
|
|
|
|
return $this->userService->getOneById($id);
|
|
|
|
}
|
2024-08-30 03:31:22 +02:00
|
|
|
|
|
|
|
public function edit(UserEditRequest $request, string $id)
|
|
|
|
{
|
|
|
|
$user = $this->userService->editUser($request->all(), $id);
|
|
|
|
if ($user === null) {
|
|
|
|
return response('', 404);
|
|
|
|
}
|
|
|
|
}
|
2024-08-30 02:17:13 +02:00
|
|
|
}
|