Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
RolePlayConfig
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 getGlobal
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSection
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 updateSection
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Models;
4
5/**
6 * RolePlayConfig Model
7 *
8 * Stores consolidated roleplay platform configuration replacing scattered parameters.
9 * Managed via CMC admin panel.
10 *
11 * @property string $type Configuration type identifier (e.g., 'global')
12 * @property array $voices Voice options by gender {male: [...], female: [...]}
13 * @property array $personalities MBTI personality definitions
14 * @property array $names Agent name pools by gender {male: [...], female: [...]}
15 * @property array $images Agent avatar URL pools by gender {male: [...], female: [...]}
16 * @property array $vapi_defaults Default VAPI settings (provider, model, temperature)
17 * @property array $default_objections Default objection categories
18 * @property array $default_scorecards Default scorecard templates per call type
19 * @property \Carbon\Carbon|null $created_at
20 * @property \Carbon\Carbon|null $updated_at
21 */
22class RolePlayConfig extends Moloquent
23{
24    /**
25     * The database table used by the model.
26     *
27     * @var string
28     */
29    protected $table = 'role_play_configs';
30
31    /**
32     * The attributes that are mass assignable.
33     *
34     * @var array<int, string>
35     */
36    protected $fillable = [
37        'type',
38        'voices',
39        'personalities',
40        'names',
41        'images',
42        'vapi_defaults',
43        'default_objections',
44        'default_scorecards',
45    ];
46
47    /**
48     * The attributes that should be cast.
49     *
50     * @var array<string, string>
51     */
52    protected $casts = [
53        'voices' => 'array',
54        'personalities' => 'array',
55        'names' => 'array',
56        'images' => 'array',
57        'vapi_defaults' => 'array',
58        'default_objections' => 'array',
59        'default_scorecards' => 'array',
60        'created_at' => 'datetime',
61        'updated_at' => 'datetime',
62    ];
63
64    /**
65     * Get the global configuration.
66     *
67     * @return self|null
68     */
69    public static function getGlobal(): ?self
70    {
71        return static::where('type', 'global')->first();
72    }
73
74    /**
75     * Get a specific config section.
76     *
77     * @param string $section The config section name (e.g., 'voices', 'personalities')
78     * @return mixed
79     */
80    public function getSection(string $section): mixed
81    {
82        return $this->getAttribute($section);
83    }
84
85    /**
86     * Update a specific config section.
87     *
88     * @param string $section The config section name
89     * @param mixed $value The new value for the section
90     * @return bool
91     */
92    public function updateSection(string $section, mixed $value): bool
93    {
94        $this->setAttribute($section, $value);
95        return $this->save();
96    }
97}