<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class JobInterest extends Model
{
    public const SOURCE_VIEWED = 'viewed';

    public const SOURCE_SAVED = 'saved';

    public const SOURCE_APPLIED = 'applied';

    protected $fillable = [
        'user_id',
        'imported_job_id',
        'source',
        'view_count',
        'first_seen_at',
        'last_seen_at',
    ];

    /**
     * @return BelongsTo<User, $this>
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    /**
     * @return BelongsTo<ImportedJob, $this>
     */
    public function importedJob(): BelongsTo
    {
        return $this->belongsTo(ImportedJob::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'view_count' => 'integer',
            'first_seen_at' => 'datetime',
            'last_seen_at' => 'datetime',
        ];
    }
}
