Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| UserVapiConfig | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| forUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models; |
| 4 | |
| 5 | /** |
| 6 | * UserVapiConfig Model |
| 7 | * |
| 8 | * Stores user-level VAPI configuration overrides for the roleplay platform. |
| 9 | * Only fields that the user wants to override from the company/global defaults |
| 10 | * need to be present in the vapi_overrides array. |
| 11 | * |
| 12 | * @property string $user_id The user ID this config belongs to |
| 13 | * @property array $vapi_overrides Sparse/partial VapiConfig overrides |
| 14 | * @property \Carbon\Carbon|null $created_at |
| 15 | * @property \Carbon\Carbon|null $updated_at |
| 16 | */ |
| 17 | class UserVapiConfig extends Moloquent |
| 18 | { |
| 19 | /** |
| 20 | * The database table used by the model. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | protected $table = 'user_vapi_configs'; |
| 25 | |
| 26 | /** |
| 27 | * The attributes that are mass assignable. |
| 28 | * |
| 29 | * @var array<int, string> |
| 30 | */ |
| 31 | protected $fillable = [ |
| 32 | 'user_id', |
| 33 | 'vapi_overrides', |
| 34 | ]; |
| 35 | |
| 36 | /** |
| 37 | * The attributes that should be cast. |
| 38 | * |
| 39 | * @var array<string, string> |
| 40 | */ |
| 41 | protected $casts = [ |
| 42 | 'vapi_overrides' => 'array', |
| 43 | 'created_at' => 'datetime', |
| 44 | 'updated_at' => 'datetime', |
| 45 | ]; |
| 46 | |
| 47 | /** |
| 48 | * Get the VAPI config overrides for a specific user. |
| 49 | * |
| 50 | * @param string $userId |
| 51 | * @return self|null |
| 52 | */ |
| 53 | public static function forUser(string $userId): ?self |
| 54 | { |
| 55 | return static::where('user_id', $userId)->first(); |
| 56 | } |
| 57 | } |