Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
RolePlayConversations
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 project
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 companyProject
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 newFactory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Models;
4
5use App\Observers\RolePlayConversationsObserver;
6use Database\Factories\Http\Models\RolePlayConversationsFactory;
7use Illuminate\Database\Eloquent\Attributes\ObservedBy;
8use Illuminate\Database\Eloquent\Factories\HasFactory;
9use MongoDB\Laravel\Eloquent\SoftDeletes;
10
11/**
12 * @property string $user_id The user ID who owns this conversation
13 * @property string|null $project_id The roleplay project ID (null for direct calls on corporate personas)
14 * @property string|null $company_project_id The corporate persona ({@see \App\Http\Models\CompanyRolePlayProject}) when this session
15 *                                           is a direct call — mutually exclusive with `project_id` at write-time.
16 * @property string|null $company_id The company ID (auto-stamped by the observer for direct corporate persona sessions)
17 * @property string $status The conversation status (created, processing, done, failed)
18 * @property string|null $vapi_call_id The VAPI call ID
19 * @property string|null $transcript The conversation transcript
20 * @property int|null $duration The conversation duration in seconds
21 * @property float|null $score The total score
22 * @property array|null $feedback The feedback data
23 * @property array|null $score_llm The raw LLM score data
24 * @property array|null $vapi_response The raw VAPI response
25 * @property string|null $prompt The user prompt
26 * @property int|null $target_duration_seconds_at_call Snapshot of the resolved
27 *                                                     target call duration at
28 *                                                     session start, used by
29 *                                                     the scoring job to
30 *                                                     compute duration adherence.
31 * @property string|array|null $icp The ICP data (JSON string or array)
32 * @property array|null $agent The agent configuration
33 * @property \Illuminate\Support\Carbon|null $created_at
34 * @property \Illuminate\Support\Carbon|null $updated_at
35 * @property-read \App\Http\Models\RolePlayProjects|null $project
36 * @property-read \App\Http\Models\CompanyRolePlayProject|null $companyProject
37 */
38#[ObservedBy([RolePlayConversationsObserver::class])]
39class RolePlayConversations extends Moloquent
40{
41    use HasFactory, SoftDeletes;
42
43    protected $table = 'role_play_conversations';
44
45    protected $fillable = [
46        'user_id',
47        'project_id',
48        'company_project_id',
49        'company_id',
50        'score',
51        'status',
52        'prompt',
53        'score_llm',
54        'vapi_response',
55        'duration',
56        'transcript',
57        'icp',
58        'agent',
59        'feedback',
60        'vapi_call_id',
61        'target_duration_seconds_at_call',
62        'updated_at',
63        'created_at',
64    ];
65
66    public function project()
67    {
68        return $this->belongsTo(RolePlayProjects::class, 'project_id');
69    }
70
71    public function companyProject()
72    {
73        return $this->belongsTo(CompanyRolePlayProject::class, 'company_project_id');
74    }
75
76    protected static function newFactory()
77    {
78        return RolePlayConversationsFactory::new();
79    }
80}