下拉菜单 多调价搜索

逻辑层

public static function show($where)
{

   return Db::name('admin')->where($where)->select();
}

public static function pay()
{
    return Db::table('pay')->select();
}

public static function logistics()
{
    return Db::table('logistics')->select();
}

控制器

public function show()
    {
        $where = [];
        $pay_type = request()->get('pay_type');
        $logistics = request()->get('logistics');
        $start = request()->get('start');
        $end = request()->get('end');
        //dd($start,$end);
        if (!empty($pay_type)){
            $where[] = [
                'pay_type','=',$pay_type,
                ];

        }

        if (!empty($logistics)){
            $where[] = [
                'logistics','=',$logistics,
            ];

        }

        if (!empty($start)&!empty($end)){
            $where[] = [
                'create_time','>=',$start,
                'create_time','<=',$end
            ];

        }

        //echo $pay_type;

        $data = \app\admin\business\show::show($where);

        //$order = \app\admin\business\show::$pay;
        $pay = \app\admin\business\show::pay();
        $logistics = \app\admin\business\show::logistics();

        return view('show',compact('data','pay','logistics'));
    }

html页面

<div>
    <form action="show" method="get">
        <input type="text" name="start">
        <input type="text" name="end">

        <select name="pay_type">
            <option value="0">支付方式</option>
            {foreach $pay as $val}
            <option value="{$val['id']}">{$val['pay_name']}</option>
            {/foreach}
        </select>

        <select name="logistics">
            <option value="0">物流类型</option>
            {foreach $logistics as $val}
            <option value="{$val['id']}">{$val['logistics_name']}</option>
            {/foreach}
        </select>

        <button type="submit">查询</button>
    </form>

猜你喜欢

转载自blog.csdn.net/QiZong__BK/article/details/123170601