<?php

namespace Modules\Bms\Entities;

use Illuminate\Database\Eloquent\Model;

/** Activity log for a QC inspection (started / submitted / voice / note). */
class BmsQcEvent extends Model
{
    protected $table = 'bms_qc_events';

    protected $fillable = ['business_id', 'inspection_id', 'type', 'detail', 'user_id'];

    public static function record(BmsQcInspection $insp, string $type, ?string $detail = null, ?int $userId = null): self
    {
        return static::create([
            'business_id'   => (int) $insp->business_id,
            'inspection_id' => $insp->id,
            'type'          => $type,
            'detail'        => $detail,
            'user_id'       => $userId,
        ]);
    }
}
