refactor: [authz] 역할/권한 API 품질 개선
- Validator::make를 FormRequest로 분리 (6개 생성) - 하드코딩 한글 문자열을 i18n 키로 교체 - RoleMenuPermission 데드코드 제거 - Role 모델 SpatieRole 상속으로 일원화 - 권한 변경 후 캐시 무효화 추가 (AccessService::bumpVersion) - 미문서화 8개 Swagger 엔드포인트 추가 - 역할/권한 라우트에 perm.map+permission 미들웨어 추가
This commit is contained in:
31
app/Http/Requests/Authz/RoleStoreRequest.php
Normal file
31
app/Http/Requests/Authz/RoleStoreRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Authz;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RoleStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$tenantId = (int) app('tenant_id');
|
||||
$guard = 'api';
|
||||
|
||||
return [
|
||||
'name' => [
|
||||
'required', 'string', 'max:100',
|
||||
Rule::unique('roles', 'name')->where(fn ($q) => $q
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('guard_name', $guard)),
|
||||
],
|
||||
'description' => 'nullable|string|max:255',
|
||||
'is_hidden' => 'sometimes|boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user