First commit

This commit is contained in:
Saufi
2026-05-18 08:56:23 +08:00
commit fd3d3a4d2b
147 changed files with 22099 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
class ProcessingLog extends Model
{
const UPDATED_AT = null;
protected $fillable = [
'processable_type',
'processable_id',
'stage',
'status',
'message',
'metadata',
'duration',
];
protected $casts = [
'metadata' => 'array',
'duration' => 'float',
];
const STAGE_UPLOAD = 'upload';
const STAGE_EXTRACT = 'extract';
const STAGE_CHUNK = 'chunk';
const STAGE_EMBED = 'embed';
const STAGE_QDRANT = 'qdrant_sync';
const STAGE_COMPLETE = 'completed';
const STAGE_FAILED = 'failed';
const STATUS_STARTED = 'started';
const STATUS_COMPLETED = 'completed';
const STATUS_FAILED = 'failed';
public function scopeForRecord(Builder $query, string $type, int $id): Builder
{
return $query->where('processable_type', $type)
->where('processable_id', $id);
}
/**
* Helper untuk log processing dengan masa
*/
public static function record(
string $type,
int $id,
string $stage,
string $status,
?string $message = null,
?array $metadata = null,
?float $duration = null
): self {
return static::create([
'processable_type' => $type,
'processable_id' => $id,
'stage' => $stage,
'status' => $status,
'message' => $message,
'metadata' => $metadata,
'duration' => $duration,
]);
}
}