42 lines
891 B
PHP
42 lines
891 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\Blameable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
|
|
class ImportLog extends Model
|
|
{
|
|
use HasFactory, SoftDeletes, Blameable;
|
|
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($model) {
|
|
try {
|
|
$model->uuid = (string) Str::orderedUuid(); // generate uuid
|
|
} catch (\Exception $e) {
|
|
abort(500, $e->getMessage());
|
|
}
|
|
});
|
|
}
|
|
|
|
protected $fillable = [
|
|
'importable_type',
|
|
'importable_id',
|
|
'type',
|
|
'file_path',
|
|
'status',
|
|
'progress',
|
|
];
|
|
|
|
public function files()
|
|
{
|
|
return $this->morphMany(File::class, 'fileable');
|
|
}
|
|
}
|