主页 > 编程 > php >

大型B2C商城实战5品牌列表显示和删除

2019-07-08 22:22 阅读:175 来源:智宇SEO自媒体
大型B2C商城实战5品牌列表显示和删除
列表显示控制器
<?php
namespace appdmincontroller;
use thinkController;
class Brand extends Controller
{
    public function lst()
    {
        $brandRes = db('brand')->paginate(2);
        $this->assign(['brandRes'=>$brandRes,]);
      return view();
    }
   
    public function del($id)
    {
        $del = db('brand')->delete($id);
        if($del)
        {
            $this->success('品牌删除成功!','lst');
        }
        else
        {
            $this->error('品牌删除失败!');
        }
    }

}


视图
<table class="table table-bordered table-hover">
  <thead class="">
    <tr>
      <th class="text-center" width="8%">ID</th>
      <th class="text-center">品牌名称</th>
      <th>品牌地址</th>
      <th class="text-center">品牌LOGO</th>
      <th>品牌描述</th>
      <th class="text-center" width="8%">品牌状态</th>
      <th class="text-center" width="14%">操作</th></tr>
  </thead>
  <tbody>{volist name="brandRes" id="brand"}
    <tr>
      <td align="center">{$brand.id}</td>
      <td>{$brand.brand_name}</td>
      <td>{$brand.brand_url}</td>
      <td align="left">{if condition="$brand['brand_img'] neq ''"}
        <img src="__uploads__/{$brand.brand_img}" height="30">{else /} 暂无图片 {/if}</td>
      <td>{$brand.brand_desc}</td>
      <td align="center">{if condition ="$brand['status'] eq 1"}
        <img src="__admin__/dui.png" height="30">{else /}
        <img scr="__admin__/cuo.png" height="30"></td>{/if}
      <td align="center">
        <a href="/admin/user/edit/id/6.html" class="btn btn-primary btn-sm shiny">
          <i class="fa fa-edit"></i>编辑</a>
        <a href="#" onClick="warning('确实要删除吗', '{:url('del',array('id'=>$brand['id']))}')" class="btn btn-danger btn-sm shiny">
          <i class="fa fa-trash-o"></i>删除</a>
      </td>
    </tr>{/volist}</tbody>
</table>
</div>
<div style="margin-top: 15px;"></div>{$brandRes ->render()}
<div>