53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Import extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'uuid', 'user_id', 'import_template_id', 'client_id', 'source_type', 'file_name', 'original_name', 'disk', 'path', 'size', 'sheet_name', 'status', 'reactivate', 'show_missing', 'total_rows', 'valid_rows', 'invalid_rows', 'imported_rows', 'started_at', 'finished_at', 'failed_at', 'error_summary', 'meta',
|
|
];
|
|
|
|
protected $casts = [
|
|
'error_summary' => 'array',
|
|
'meta' => 'array',
|
|
'started_at' => 'datetime',
|
|
'finished_at' => 'datetime',
|
|
'failed_at' => 'datetime',
|
|
'reactivate' => 'boolean',
|
|
'show_missing' => 'boolean',
|
|
];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function template(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ImportTemplate::class, 'import_template_id');
|
|
}
|
|
|
|
public function client(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Client::class);
|
|
}
|
|
|
|
public function rows(): HasMany
|
|
{
|
|
return $this->hasMany(ImportRow::class);
|
|
}
|
|
|
|
public function events(): HasMany
|
|
{
|
|
return $this->hasMany(ImportEvent::class);
|
|
}
|
|
}
|