55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Item-item co-occurrence pair for behavior-based similarity.
|
|
*
|
|
* @property int $a_artwork_id
|
|
* @property int $b_artwork_id
|
|
* @property float $weight
|
|
* @property \Carbon\Carbon $updated_at
|
|
*
|
|
* @property-read Artwork $artworkA
|
|
* @property-read Artwork $artworkB
|
|
*/
|
|
final class RecItemPair extends Model
|
|
{
|
|
protected $table = 'rec_item_pairs';
|
|
|
|
public $incrementing = false;
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = [
|
|
'a_artwork_id',
|
|
'b_artwork_id',
|
|
'weight',
|
|
'updated_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'a_artwork_id' => 'integer',
|
|
'b_artwork_id' => 'integer',
|
|
'weight' => 'double',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
// ── Relations ──────────────────────────────────────────────────────────
|
|
|
|
public function artworkA(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Artwork::class, 'a_artwork_id');
|
|
}
|
|
|
|
public function artworkB(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Artwork::class, 'b_artwork_id');
|
|
}
|
|
}
|