RecycleController.php 1.7 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/8
 * Time: 14:19
 */

namespace app\index\controller;


use app\index\model\NorecyclegoodsModel;
use app\index\model\NorecycletypeModel;
use app\index\model\RecyclegoodsModel;
use app\index\model\RecycletypeModel;
use cmf\controller\HomeBaseController;

class RecycleController extends HomeBaseController
{
    //可回收物
    public function index(){
        $where['delete_time'] = ['eq',0];
        $recycleModel = new RecycletypeModel();
        $data = $recycleModel->selectData($where)->toArray();
        $recycleGoodsModel = new RecyclegoodsModel();
        $tiao = [];
        $res = $recycleGoodsModel->selectData($tiao)->toArray();
        foreach ($data as &$v){
            $v['recyclegoods'] = [];
            foreach ($res as $key=>$val){
                if($val['recycletype_id'] == $v['id']){
                    array_push($v['recyclegoods'],$val);
                }
            }
        }
        $this->assign('data',$data);
        return $this->fetch();
    }

    //不可回收物
    public function noRecycle()
    {
        $where['delete_time'] = ['eq',0];
        $recycleModel = new NorecycletypeModel();
        $data = $recycleModel->selectData($where)->toArray();
        $recycleGoodsModel = new NorecyclegoodsModel();
        $tiao = [];
        $res = $recycleGoodsModel->selectData($tiao)->toArray();
        foreach ($data as &$v){
            $v['norecyclegoods'] = [];
            foreach ($res as $key=>$val){
                if($val['recycletype_id'] == $v['id']){
                    array_push($v['norecyclegoods'],$val);
                }
            }
        }
        $this->assign('data',$data);
        return $this->fetch();
    }
}