返回小型企业站分类......登陆

小型企业站分类模块

12019-06-16 10:08:0965

<?php

namespace app\admin\controller;

use think\Controller;

use app\admin\model\User;

use app\admin\model\Sort;

use think\facade\Session;

use think\facade\Request;

use app\admin\controller\Commn;


class Sortl extends Commn

{

public function index()

{

$res = Sort::order('sort_id','desc')->paginate(4);


$page = $res->render();


$this->assign('res',$res);


$this->assign('page',$page);


return $this->fetch();

}

public function index_do()

{

$data = Request::param();


$data['username'] = Session::get('username');


$data['sort_create_time'] = time();


$sort_name = $data['sort_name'];


if ($res = Sort::where('sort_name',$sort_name)->find()) {

return json(['code'=>1,'msg'=>'不可以添加重复分类']);

}

if ($sort = Sort::insert($data)) {

return json(['code'=>2,'msg'=>'添加分类成功']);

}else{

return json(['code'=>3,'msg'=>'添加分类失败']);

}

}

public function upl()

{

$data = Request::param();


$sort_id = $data['id'];


$res = Sort::where('sort_id',$sort_id)->find();


$this->assign('res',$res);


return $this->fetch();

}

public function upl_do()

{

$data = Request::param();

//验证唯一

$sort_id = $data['sort_id'];

//查询

// $res = Sort::where('sort_id',$sort_id)->find();


// if ($res['sort_name'] == $data['sort_name']) {

// if ($res = Sort::where('sort_id',$sort_id)->update($data)) {

// return json(['code'=>1,'msg'=>'修改分类成功']);

// }else{

// return json(['code'=>2,'msg'=>'修改操作错误,请重新修改']);

// }

// }

if ($Sort = Sort::where('sort_id',$sort_id)->update($data)) {

return json(['code'=>1,'msg'=>'修改分类成功']);

}else{

return json(['code'=>2,'msg'=>'修改操作错误,请重新修改']);

}

}

public function del()

{

$data = Request::param();


$sort_id = $data['id'];


if ($res = Sort::where('sort_id',$sort_id)->delete()) {

return json(['code'=>1,'msg'=>'删除分类成功']);

}else{

return json(['code'=>2,'msg'=>'删除分类失败']);

}


}

}

HO~XI$@6DO41I7MYZG58LTB.png

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送
  • PHP中文网