<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * Class UssdPayment
 * @package App
 *
 * Payments made to activate the ussd are handled by this model
 */
class UssdPayment extends Model
{

    /**
     * Payment constant
     */
    const MONTHLY_AMOUNT = 200;


    /**
     * @var array
     */
    protected $fillable = [
        'ussd_service_id',
        'amount',
        'transaction_id',
        'status', //set by the payment response callback
        'response_message', //set by the payment response callback
        'payment_date', //date payment was made
        'expiry_date', //date payment will expire
        'has_expired'
    ];

    /**
     * @var array
     */
    protected $casts = [
        'has_expired' => 'boolean'
    ];

    /**
     * @var string[]
     */
    protected $dates = [
        'payment_date',
        'expiry_date'
    ];

    /**
     * A service question is related to the Ussd Service
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function ussd_service() {
        return $this->belongsTo(UssdService::class);
    }
}
