<?php

namespace App\Modelos;

use Core\Database;

class MetodoPago extends Database
{
    protected $table = 'app_metodopago';
    protected $id = 'mp_id';

    public function obtenerMetodosPagoActivos()
    {
        return $this->consultar('SELECT * FROM  app_metodopago WHERE mp_estatus=1')->all();
    }

    public function obtenerMetodosPago()
    {
        return $this->consultar('SELECT * FROM  app_metodopago')->all();
    }

    public function actualizarEstatus($mp_id, $mp_estatus)
    {
        return $this->consultar("UPDATE app_metodopago SET mp_estatus = $mp_estatus WHERE mp_id=$mp_id")->run();
    }    

    public function chequearForanero($id_metodo)
    {
        return $this->consultar("SELECT * 
        FROM  app_metodopago m
        JOIN app_metodopago_divisa md ON m.mp_id = md_mpid
        WHERE mp_id = $id_metodo")->all();
    }

    public function obtenerMetodoPagoComisiones($id_divisa)
    {
        return $this->consultar("SELECT * 
        FROM  app_metodopago m
        JOIN app_metodopago_divisa md ON m.mp_id = md_mpid
        WHERE md_divid = $id_divisa")->all();
    }
}
