Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
71.43% covered (warning)
71.43%
5 / 7
33.33% covered (danger)
33.33%
1 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ImportErrorModel
71.43% covered (warning)
71.43%
5 / 7
33.33% covered (danger)
33.33%
1 / 3
3.21
0.00% covered (danger)
0.00%
0 / 1
 casts
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 newFactory
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 job
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace ImovelZapAi\Importing\Infrastructure\Persistence\Eloquent;
6
7use Database\Factories\ImportErrorFactory;
8use Illuminate\Database\Eloquent\Factories\HasFactory;
9use Illuminate\Database\Eloquent\Model;
10use Illuminate\Database\Eloquent\Relations\BelongsTo;
11use ImovelZapAi\Importing\Domain\Enums\ImportIssueSeverity;
12use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\BelongsToTenant;
13use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey;
14
15class ImportErrorModel extends Model
16{
17    use BelongsToTenant;
18    use HasFactory;
19    use HasUuidPrimaryKey;
20
21    protected $table = 'import_errors';
22
23    protected $fillable = [
24        'tenant_id',
25        'import_job_id',
26        'severity',
27        'code',
28        'external_id',
29        'listing_index',
30        'path',
31        'message',
32        'resolution',
33        'status',
34        'context',
35    ];
36
37    protected function casts(): array
38    {
39        return [
40            'severity' => ImportIssueSeverity::class,
41            'context' => 'array',
42            'listing_index' => 'integer',
43        ];
44    }
45
46    protected static function newFactory(): ImportErrorFactory
47    {
48        return ImportErrorFactory::new();
49    }
50
51    public function job(): BelongsTo
52    {
53        return $this->belongsTo(ImportJobModel::class, 'import_job_id');
54    }
55}