44 خطوط
1.0 KiB
PHP
44 خطوط
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class ImportBatch extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id', 'filename', 'total_rows', 'imported_rows',
|
|
'skipped_rows', 'failed_rows', 'status', 'column_mapping',
|
|
'campaign_id', 'errors', 'can_rollback',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'column_mapping' => 'array',
|
|
'can_rollback' => 'boolean',
|
|
'total_rows' => 'integer',
|
|
'imported_rows' => 'integer',
|
|
'skipped_rows' => 'integer',
|
|
'failed_rows' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function campaign(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Campaign::class);
|
|
}
|
|
|
|
public function rows(): HasMany
|
|
{
|
|
return $this->hasMany(ImportBatchRow::class);
|
|
}
|
|
}
|