RecycleController.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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();
}
}