Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CompanyRolePlaySettings
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 company
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 scopeForCompany
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\Http\Models\Admin\Company;
6
7/**
8 * Company-wide defaults for the RolePlay feature.
9 *
10 * One document per company. Unset fields fall back to the global
11 * {@see RolePlayConfig} defaults at read time; this model only records
12 * what the admin has explicitly overridden.
13 *
14 * @property string $company_id
15 * @property string|null $default_call_type
16 * @property int|null $default_difficulty
17 * @property string|null $default_voice
18 * @property array|null $feature_toggles
19 * @property \Carbon\Carbon|null $created_at
20 * @property \Carbon\Carbon|null $updated_at
21 */
22class CompanyRolePlaySettings extends Moloquent
23{
24    /**
25     * @var string
26     */
27    protected $table = 'company_roleplay_settings';
28
29    /**
30     * @var array<int, string>
31     */
32    protected $fillable = [
33        'company_id',
34        'default_call_type',
35        'default_difficulty',
36        'default_voice',
37        'feature_toggles',
38    ];
39
40    /**
41     * @var array<string, string>
42     */
43    protected $casts = [
44        'default_difficulty' => 'integer',
45        'feature_toggles' => 'array',
46        'created_at' => 'datetime',
47        'updated_at' => 'datetime',
48    ];
49
50    public function company()
51    {
52        return $this->belongsTo(Company::class, 'company_id');
53    }
54
55    /**
56     * @param  \Illuminate\Database\Eloquent\Builder  $query
57     */
58    public function scopeForCompany($query, string $companyId)
59    {
60        return $query->where('company_id', $companyId);
61    }
62}