39 lines
783 B
PHP
39 lines
783 B
PHP
<?php
|
|
|
|
namespace Modules\IntegrationHub\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class IhExportJob extends Model
|
|
{
|
|
protected $table = 'ih_export_jobs';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'completed_at' => 'datetime',
|
|
];
|
|
|
|
public function scopeForBusiness($query, int $businessId)
|
|
{
|
|
return $query->where('business_id', $businessId);
|
|
}
|
|
|
|
public function markCompleted(string $filePath): void
|
|
{
|
|
$this->update([
|
|
'status' => 'completed',
|
|
'file_path' => $filePath,
|
|
'completed_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function markFailed(): void
|
|
{
|
|
$this->update([
|
|
'status' => 'failed',
|
|
'completed_at' => now(),
|
|
]);
|
|
}
|
|
}
|