Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.31% covered (success)
92.31%
12 / 13
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
StoreIntegration
92.31% covered (success)
92.31%
12 / 13
75.00% covered (warning)
75.00%
3 / 4
4.01
0.00% covered (danger)
0.00%
0 / 1
 casts
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
 tenant
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 store
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 provider
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Models;
4
5use App\Enums\IntegrationStatus;
6use Illuminate\Database\Eloquent\Factories\HasFactory;
7use Illuminate\Database\Eloquent\Model;
8use Illuminate\Database\Eloquent\Relations\BelongsTo;
9
10class StoreIntegration extends Model
11{
12    use HasFactory;
13
14    protected $fillable = [
15        'tenant_id', 'store_id', 'provider_id', 'external_store_id', 'access_token', 'refresh_token',
16        'scopes', 'status', 'installed_at', 'disconnected_at', 'metadata', 'last_synced_at',
17    ];
18
19    protected $hidden = ['access_token', 'refresh_token'];
20
21    protected function casts(): array
22    {
23        return [
24            'status' => IntegrationStatus::class,
25            'access_token' => 'encrypted',
26            'refresh_token' => 'encrypted',
27            'scopes' => 'array',
28            'metadata' => 'array',
29            'installed_at' => 'datetime',
30            'disconnected_at' => 'datetime',
31            'last_synced_at' => 'datetime',
32        ];
33    }
34
35    public function tenant(): BelongsTo { return $this->belongsTo(Tenant::class); }
36    public function store(): BelongsTo { return $this->belongsTo(Store::class); }
37    public function provider(): BelongsTo { return $this->belongsTo(IntegrationProvider::class, 'provider_id'); }
38}