【问题标题】:I need showing filter's list我需要显示过滤器列表
【发布时间】:2021-05-24 17:50:14
【问题描述】:

我正在过滤并且在我的 dd($search) 上显示数据,但不是我的刀片

我认为这是退货的问题。

$req1 = $request->has('searchByStatus');

if ($req1 && $request->input('searchByStatus') === 'open')//same with closed
    { 
        $search = MaintenanceTasks::select(
            'Start_date_reparation'
        )
       ->where('Start_date_reparation','like' ,'1999-11-11 00:00:00')
       ->get();  
       dd($search);
    }

return view('/otList', [
    'searchByStatus'=>$req1,
    'search'=>$search
]);

blade.php 我总结了一下

    <select type="text" name="searchByStatus">
            <option value="open">open</option>
            <option value="closed">closed</option>           
    </select>
    <button type="submit">Search</button>
 @foreach($search as $otList)
 @if(($otList->getDateString() == '1999-11-11 00:00:00'))
                            <label>open</label>
                            @else
                            <label>closed</label>   
                            @endif

【问题讨论】:

    标签: php laravel search filter


    【解决方案1】:

    dd() (die and dump) 停止执行您的函数,因此假设您的 if 条件为真,您将不会返回到您的 view

    if ($req1 && $request->input('searchByStatus') === 'open') { 
        $search = MaintenanceTasks::select('Start_date_reparation')
           ->where('Start_date_reparation','like' ,'1999-11-11 00:00:00')
           ->get();  
    
           // this is preventing the rest of your function executing
           dd($search);
    }
    

    您可以改用dump($search);,它与此类似,但不会阻止函数的其余部分执行。

    【讨论】:

    • 好吧,但它显示的是相同的黑色图表,我需要它显示在列表中
    • @Tatiana 您可以将刀片代码添加到您的问题中吗?
    • 你试过调试你的foreach循环吗?你有一个条件可能会阻止页面上输出任何内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    • 2012-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多