<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * Class UserPlan
 *
 * @property int $id
 * @property int $user_id
 * @property int $plan_id
 * @property Carbon|null $current_period_end
 * @property Carbon|null $cancel_at
 * @property Carbon|null $canceled_at
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 */
class UserPlan extends Model
{
    protected $table = 'user_plans';

    protected $casts = [
        'user_id' => 'int',
        'plan_id' => 'int',
        'current_period_end' => 'datetime',
        'cancel_at' => 'datetime',
        'canceled_at' => 'datetime',
    ];

    protected $fillable = [
        'user_id',
        'plan_id',
        'current_period_end',
        'cancel_at',
        'canceled_at',
    ];

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

    public function plan()
    {
        return $this->belongsTo(Plan::class, 'plan_id');
    }
}
