<?php

namespace App\Models;

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

/**
 * Represents a user's "favourite" bookmark on an artwork.
 *
 * @property int         $id
 * @property int         $user_id
 * @property int         $artwork_id
 * @property int|null    $legacy_id   Original favourite_id from the old site
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 *
 * @property-read User    $user
 * @property-read Artwork $artwork
 */
class ArtworkFavourite extends Model
{
    protected $table = 'artwork_favourites';

    protected $fillable = [
        'user_id',
        'artwork_id',
        'legacy_id',
    ];

    protected $casts = [
        'user_id'    => 'integer',
        'artwork_id' => 'integer',
        'legacy_id'  => 'integer',
    ];

    // ── Relations ──────────────────────────────────────────────────────────

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function artwork(): BelongsTo
    {
        return $this->belongsTo(Artwork::class);
    }
}
