dongzichan2886 2018-12-03 11:32
浏览 115
已采纳

Laravel - 选择要在表格中显示的数据

I want to ask if ever I can limit my data in table. I want to remove one data out of my 6 data.

here is my table

Now I want to remove number 3 row which is SESSION_VALIDITY how can I remove that data and make it just 5 data in my table? I want to limit my data coz' I dont need to view SESSION_VALIDITY. help thanks

my Index

 @foreach ($settings as $setting)
                <tr>
                    <td>{{ $setting->settings_code }}</td>
                    <td>{{ $setting->subject}}</td>
                    <td>{{ $setting->description }}</td>

                    <td><a href="/admin/settings/{{ $setting->id }}/edit" class="fa fa-edit btn btn-info"></a></td>
                </tr>      
                @endforeach

my Controller

 public function index()
{
    $settings = Setting::all();
    return view('admin.settings.index', compact('settings'));
}
  • 写回答

4条回答 默认 最新

  • doulao2029 2018-12-03 11:38
    关注

    If you just want to not show that row in your $settings data, you can exclude it using your query like this.

    public function index()
    {
        $settings = Setting::where('settings_code', '<>', 'SESSION_VALIDITY')->get();
        return view('admin.settings.index', compact('settings'));
    }
    

    If you want to delete it entirely, you can run a one-time function to delete that row from the table.

    public function deleteSessionValidity()
    {
        $setting = Setting::where('settings_code', 'SESSION_VALIDITY')->first();
        $setting->delete();
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)