with('category') ->where('is_active', true) ->when( $request->string('category')->isNotEmpty(), fn ($query) => $query->whereHas( 'category', fn ($categoryQuery) => $categoryQuery->where('slug', $request->string('category')) ) ) ->orderBy('title') ->get(); return $this->success('قالب‌ها با موفقیت دریافت شد.', [ 'templates' => TemplateResource::collection($templates), ]); } #[OA\Get( path: '/templates/{slug}', description: 'Get a template details including its fillable keys', summary: 'Show template', tags: ['Templates'], parameters: [ new OA\Parameter(name: 'slug', description: 'Template slug', in: 'path', required: true, schema: new OA\Schema(type: 'string')), ], responses: [ new OA\Response( response: 200, description: 'Template fetched successfully', content: new OA\JsonContent( properties: [ new OA\Property(property: 'message', type: 'string', example: 'قالب با موفقیت دریافت شد.'), new OA\Property( property: 'data', properties: [ new OA\Property(property: 'template', ref: '#/components/schemas/Template'), ], type: 'object' ), ] ) ), new OA\Response(response: 404, description: 'Template not found'), ] )] public function show(Template $template): JsonResponse { $template->load('category', 'keys'); return $this->success('قالب با موفقیت دریافت شد.', [ 'template' => new TemplateResource($template), ]); } }