<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;

/**
 * Where one field's value came from.
 *
 * This is what stops a value the user stated being quietly replaced by a guess
 * when a lookup fails, which is how a campaign built for one country ends up
 * running in another.
 */
#[Fillable(['artifactable_type', 'artifactable_id', 'field', 'source'])]
class ArtifactFieldSource extends Model
{
    /** The user said it. Trusted. */
    public const USER_STATED = 'user_stated';

    /** A platform returned it. Trusted. */
    public const PLATFORM_RETURNED = 'platform_returned';

    /** The model worked it out from context. Usable, worth showing. */
    public const MODEL_INFERRED = 'model_inferred';

    /** The model guessed after something failed. Must be confirmed before it can spend. */
    public const FALLBACK = 'fallback';

    public function artifactable(): MorphTo
    {
        return $this->morphTo();
    }
}
