<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class VoucherClaim extends Model
{
    use HasFactory;

    protected $table = 'voucher_claims';
    protected $primaryKey = 'id';
    public $incrementing = true;
    protected $keyType = 'int';

    protected $fillable = [
        'time',
        'voucher_id',
        'user_id',
        'claimable_id',
        'claimable_type',
        'claimer_id',
        'claimer_type'
    ];

    public function user() {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public function claimable(){
        return $this->morphTo();
    }

    public function claimer(){
        return $this->morphTo();
    }

    public function voucher(){
        return $this->belongsTo(Voucher::class);
    }

}
