megahunt.test/app/Http/Controllers/PrivateUserController.php

41 lines
976 B
PHP

<?php
namespace App\Http\Controllers;
use App\Facade\Filters\Filters;
use App\Http\Requests\AuthorizedRequest;
use App\Http\Requests\UserEditRequest;
use App\Services\UserService;
class PrivateUserController extends Controller
{
public function __construct(
private UserService $userService
) {
}
public function list(AuthorizedRequest $request)
{
return $this->userService->listAll();
}
public function listFilters(AuthorizedRequest $request)
{
$filters = Filters::fromArrayOrObject($request->all());
return $this->userService->listAll($filters);
}
public function get(AuthorizedRequest $request, string $id)
{
return $this->userService->getOneById($id);
}
public function edit(UserEditRequest $request, string $id)
{
$user = $this->userService->editUser($request->all(), $id);
if ($user === null) {
return response('', 404);
}
}
}