<?php

namespace App\Modelos;

use Core\Database;

class Almacen_Sucursales extends Database
{
    protected $table = 'app_almacen_sucursal';
    protected $id = 'alsu_id';

    public function obtenerAlmacenesSucursales($id)
    {
        return $this->consultar("SELECT * FROM 
        app_almacenes a 
        JOIN app_almacen_sucursal alms ON alms.alsu_almid = a.alm_id 
        JOIN app_sucursales su ON su.su_id = alms.alsu_suid 
        WHERE a.alm_id =$id")->all();
    }

    public function existeSucursal($almacen,$sucursal)
    {
        return $this->consultar("SELECT * FROM app_almacen_sucursal WHERE alsu_almid =$almacen AND alsu_suid=$sucursal")->row();
    }

    public function obtenerSucursales()
    {
        return $this->consultar("SELECT * FROM app_sucursales")->all();
    }

}
