<?php

namespace App\Models_v2;

use App\Models\Achievement;
use App\User;
use Illuminate\Database\Eloquent\Model;

class Transaction extends Model {
	//
	protected $table = 'transaction_find_hostels';

	const VOUCHER = 0; // loại hệ thống thêm
	const CHARGE  = 1; // nạp tiền
	const BUY_INTERACT = 2; // mua tương tác
	const FIND_RENTER_SUCCESS = 3; // Tìm khách thuê thành công
	const FIND_HOSTEL_SUCCESS = 4; // Tìm nhà thành công

	const STATUS_NOT_PROCESS = 0;
	const STATUS_PROCESSED =1;


	protected $fillable = [
		'user_id',
		'amount',
		'request_confirm_id',
		'type',
		'hostel_id',
		'achievement_id',
		'status',
		'charge_from',
		'request_log',
		'response_log',
		'order_id',
		'wallet_trans_id'
	];

	protected $casts = [
		'request_log' => 'array',
		'response_log' => 'array',
	];

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

	public function achievement()
	{
		return $this->belongsTo(Achievement::class);
	}
}
