<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class PaymentProvider extends Model
{
    protected $table = 'payment_provider';

    protected $fillable = [
        'id',
        'name',
        'status'
    ];

    public function afaOrderPayments()
    {
        return $this->hasMany(AFAOrderPayment::class, 'payment_provider_id');
    }

    public function ishareOrderPayments()
    {
        return $this->hasMany(IshareOrderPayment::class, 'payment_provider_id');
    }

    public function orderPayments()
    {
        return $this->hasMany(OrderPayment::class, 'payment_provider_id');
    }

    public function walletTransactions()
    {
        return $this->hasMany(WalletTransaction::class, 'payment_provider_id');
    }

    public function scopeActiveProvider($query)
    {
        return $query->where('status', true)->first();
    }

    public function scopeIsBulkClix($query)
    {
        $bulkclix = $query->where('name', 'bulkclix')->where('status', true)->first();
        return $bulkclix ? $bulkclix : false;
    }

    public function scopeIsMoorle($query)
    {
        $moorle = $query->where('name', 'moorle')->where('status', true)->first();
        return $moorle ? $moorle : false;
    }
}
