<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Validator;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Transaction extends Model
{
    use HasFactory;

    protected $table = 'transactions';

    protected $fillable = [
        'user_id',
        'payment_id',
        'request_amount',
        'comment',
        'expired_date',
        'date',
    ];
    public function validate($input)
    {
        $validate = Validator::make($input, [
            'request_amount' => 'required',
            'comment' => 'required',
            'expired_date' => 'required',
            'user_id' => 'required',
            'payment_id' => 'required',
        ]);

        return $validate;
    }

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