Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
31 / 31
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
AIPromptResource
100.00% covered (success)
100.00%
31 / 31
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
31 / 31
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Resources\v2;
4
5use Illuminate\Http\Request;
6use Illuminate\Http\Resources\Json\JsonResource;
7
8/**
9 * Resource for transforming AIPrompts models for API responses.
10 *
11 * @property string $_id The AI prompt ID
12 * @property string $product The product identifier
13 * @property string $name The action/prompt name
14 * @property string|null $model The AI model identifier
15 * @property int $version The prompt version number
16 * @property float|null $temperature The model temperature setting
17 * @property int|null $tokens The maximum token limit
18 * @property float|null $top_p The top_p sampling parameter
19 * @property string|null $mission The mission/goal of the prompt
20 * @property string|null $context The context description
21 * @property string|null $persona The persona description
22 * @property array|null $instructions List of instructions
23 * @property array|null $examples Input/output examples
24 * @property array|null $constraints List of constraints
25 * @property array|null $output_instructions Output formatting instructions
26 * @property float|null $threshold Score threshold
27 * @property bool|null $is_grounding Whether grounding is enabled
28 * @property string|null $include_hashtags_prompt Hashtag inclusion prompt
29 * @property string|null $exclude_hashtags_prompt Hashtag exclusion prompt
30 * @property string|null $include_emojis_prompt Emoji inclusion prompt
31 * @property string|null $exclude_emojis_prompt Emoji exclusion prompt
32 * @property string|null $existent_content_instructions Regeneration instructions
33 * @property array|null $existent_content_constraints Regeneration constraints
34 * @property string|null $youtube_url_mission YouTube post mission
35 * @property string|null $blog_url_mission Blog post mission
36 * @property array|null $youtube_url_instructions YouTube post instructions
37 * @property array|null $blog_url_instructions Blog post instructions
38 * @property \Carbon\Carbon|null $created_at
39 * @property \Carbon\Carbon|null $updated_at
40 */
41class AIPromptResource extends JsonResource
42{
43    /**
44     * Transform the resource into an array.
45     *
46     * @return array<string, mixed>
47     */
48    public function toArray(Request $request): array
49    {
50        return [
51            'id' => (string) $this->_id,
52            'product' => $this->product,
53            'name' => $this->name,
54            'model' => $this->model,
55            'version' => (int) $this->version,
56            'temperature' => $this->temperature,
57            'tokens' => $this->tokens,
58            'top_p' => $this->top_p,
59            'mission' => $this->mission,
60            'context' => $this->context,
61            'persona' => $this->persona,
62            'instructions' => $this->instructions,
63            'examples' => $this->examples,
64            'constraints' => $this->constraints,
65            'output_instructions' => $this->output_instructions,
66            'threshold' => $this->threshold,
67            'is_grounding' => (bool) $this->is_grounding,
68            'include_hashtags_prompt' => $this->include_hashtags_prompt,
69            'exclude_hashtags_prompt' => $this->exclude_hashtags_prompt,
70            'include_emojis_prompt' => $this->include_emojis_prompt,
71            'exclude_emojis_prompt' => $this->exclude_emojis_prompt,
72            'existent_content_instructions' => $this->existent_content_instructions,
73            'existent_content_constraints' => $this->existent_content_constraints,
74            'youtube_url_mission' => $this->youtube_url_mission,
75            'blog_url_mission' => $this->blog_url_mission,
76            'youtube_url_instructions' => $this->youtube_url_instructions,
77            'blog_url_instructions' => $this->blog_url_instructions,
78            'created_at' => $this->created_at?->timestamp,
79            'updated_at' => $this->updated_at?->timestamp,
80        ];
81    }
82}