Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RolePlayObjectionsRepository
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 defaultsForCompanySize
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Repositories;
4
5use App\Http\Models\RolePlayObjections;
6use Illuminate\Support\Collection;
7
8/**
9 * Repository for the seeded RolePlayObjections collection.
10 *
11 * The persona builder lets users layer their own custom objections on top
12 * of seeded defaults; this repository exposes the queries used at session
13 * start to pull the relevant defaults for a specific call type and ICP
14 * company size, so the prompt builder can merge them into the system prompt.
15 *
16 * Defaults are scoped by:
17 *  - call_type (cold-call|discovery-call)
18 *  - company_size (small|medium|large|all) — matched against the ICP's size
19 *  - status (active)
20 */
21class RolePlayObjectionsRepository
22{
23    /**
24     * List active default objections for a given call type and company-size key.
25     *
26     * Returns rows where company_size is either the requested size OR 'all'
27     * (size-agnostic defaults). Excludes any rows whose id appears in
28     * $excludedIds (used to skip defaults the user removed from a persona).
29     *
30     * @param  string  $callType  cold-call|discovery-call
31     * @param  string  $companySizeKey  small|medium|large
32     * @param  array<int, string>  $excludedIds  Default-objection ids the user removed from this persona
33     * @return Collection<int, RolePlayObjections>
34     */
35    public function defaultsForCompanySize(string $callType, string $companySizeKey, array $excludedIds = []): Collection
36    {
37        return RolePlayObjections::where('call_type', $callType)
38            ->where('status', 'active')
39            ->whereIn('company_size', [$companySizeKey, 'all'])
40            ->when(! empty($excludedIds), fn ($q) => $q->whereNotIn('_id', $excludedIds))
41            ->get();
42    }
43}