Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
76.92% |
10 / 13 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
| ImportLogModel | |
76.92% |
10 / 13 |
|
25.00% |
1 / 4 |
4.20 | |
0.00% |
0 / 1 |
| casts | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| newFactory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| job | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| property | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Importing\Infrastructure\Persistence\Eloquent; |
| 6 | |
| 7 | use Database\Factories\ImportLogFactory; |
| 8 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 9 | use Illuminate\Database\Eloquent\Model; |
| 10 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 11 | use ImovelZapAi\Importing\Domain\Enums\ImportLogEvent; |
| 12 | use ImovelZapAi\Properties\Infrastructure\Persistence\Eloquent\PropertyModel; |
| 13 | use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\BelongsToTenant; |
| 14 | use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey; |
| 15 | |
| 16 | class ImportLogModel extends Model |
| 17 | { |
| 18 | use BelongsToTenant; |
| 19 | use HasFactory; |
| 20 | use HasUuidPrimaryKey; |
| 21 | |
| 22 | public $timestamps = false; |
| 23 | |
| 24 | protected $table = 'import_logs'; |
| 25 | |
| 26 | protected $fillable = [ |
| 27 | 'tenant_id', |
| 28 | 'import_job_id', |
| 29 | 'property_id', |
| 30 | 'external_id', |
| 31 | 'listing_index', |
| 32 | 'event', |
| 33 | 'result', |
| 34 | 'diff_before', |
| 35 | 'diff_after', |
| 36 | 'photos_count', |
| 37 | 'duration_ms', |
| 38 | 'message', |
| 39 | 'context', |
| 40 | 'created_at', |
| 41 | ]; |
| 42 | |
| 43 | protected function casts(): array |
| 44 | { |
| 45 | return [ |
| 46 | 'event' => ImportLogEvent::class, |
| 47 | 'diff_before' => 'array', |
| 48 | 'diff_after' => 'array', |
| 49 | 'context' => 'array', |
| 50 | 'created_at' => 'datetime', |
| 51 | 'listing_index' => 'integer', |
| 52 | 'photos_count' => 'integer', |
| 53 | 'duration_ms' => 'integer', |
| 54 | ]; |
| 55 | } |
| 56 | |
| 57 | protected static function newFactory(): ImportLogFactory |
| 58 | { |
| 59 | return ImportLogFactory::new(); |
| 60 | } |
| 61 | |
| 62 | public function job(): BelongsTo |
| 63 | { |
| 64 | return $this->belongsTo(ImportJobModel::class, 'import_job_id'); |
| 65 | } |
| 66 | |
| 67 | public function property(): BelongsTo |
| 68 | { |
| 69 | return $this->belongsTo(PropertyModel::class, 'property_id'); |
| 70 | } |
| 71 | } |