You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.7 KiB
PHP

<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ItemController extends Controller
{
//获取全部自选项目
public function GetItems()
{
//查询所有可以自选的项目
$items=DB::table('items')->where(['is_choose'=>1,'status'=>1])->get();
$search= request('search');
$list = [];
$group_arr = [];
$group_list = [];
foreach ($items as $item) {
$push_type = false;
if ($search == '') {
$push_type = true;
} else {
$check_name = $item->name;
if (strpos($check_name, $search) !== false) {
$push_type = true;
}
$check_py = $item->pinyin;
if (strpos($check_py, mb_strtoupper($search)) !== false) {
$push_type = true;
}
$check_group = $item->keshi_name;
if (strpos($check_group, $search) !== false) {
$push_type = true;
}
}
if ($push_type) {
if (!in_array($item->keshi_id, $group_arr)) {
$group_list["科室{$item->keshi_id}"] = [
'id' => $item->keshi_id,
'title' => $item->keshi_name,
'children' => [],
];
$group_arr[] = $item->keshi_id;
}
$group_list["科室{$item->keshi_id}"]['children'][] = [
'id' => $item->item_id,
'title' => $item->name,
'price' =>$item->price,
'original_price'=>$item->original_price,
'pinyin' => $item->pinyin,
];
}
}
return \Yz::Return(true,"查询成功",['list'=>$group_list]);
}
}