~~~
<?php
namespace app\admin\controller;
use app\common\controller\AdminBase;
use think\Db;
use think\Session;
class Imgfile extends AdminBase
{
protected function _initialize()
{
parent::_initialize();
$file_tag = model('ImgfileTag')->order('sort desc,id asc')->select();
$this->assign('file_tag',$file_tag);
}
public function index($t_id=1)
{
return $this->fetch('index',['tag_id' =>$t_id]);
//$this->redirect('imgfile/show', ['tag_id' =>1]);
//$this->redirect('About/show', ['id' =>$id,'kid'=>$kid]);
}
public function home()
{
// return $this->fetch('index',['tag_id' =>$t_id]);
$this->redirect('imgfile/index', ['tag_id' =>1]);
//$this->redirect('About/show', ['id' =>$id,'kid'=>$kid]);
}
public function show($tag_id=1)
{
$url= $_SERVER['HTTP_HOST'];
$file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->select();
$this->assign([
'file'=>$file,
'root'=>$url,
'tag'=>$tag_id
]);
return $this->fetch("show", ['tag_id' =>$tag_id]);
}
//编辑1-1
public function edit($id)
{
$apage=Db::table('yp_imgfile')->where('id',$id)->find();
$this->assign('apage',$apage);
return $this->fetch();
}
//编辑1-2
public function update($id)
{
$status = 0;
$message = "更新失败";
$data = $this->request->param();
$data['create_time'] = time();
if (model('Imgfile')->allowField(true)->save($data, ['id' => $data['id']])) {
$status = 1;
$message = '更新成功';
}
return ['status'=>$status,'message'=>$message];
}
//编辑1-3
public function edittag()
{
return $this->fetch();
}
//编辑1-4
public function tag()
{
$status=1;
$data = $this->request->param();
$allid = $data['id'];
$ids='';
foreach($allid as $k=>$value){
$ids[$k]=$value;
}
$num = count($allid);
return ['status'=>$status,'ids'=> $ids];
}
//编辑1-5
public function updatetag()
{
$status = 0;
$message = "更新失败";
$data = $this->request->param();
$tag_id=$data['tag_id'];
$ids=$data['ids'];
// halt($ids);
if(Db::table('yp_imgfile')->where('id','in',$ids)->setField('tag_id',$tag_id)){
$status = 1;
$message = "更新成功";
}
return ['status'=>$status,'message'=>$message];
}
//删除
public function delete($id)
{
$message="删除失败";
if(model('Imgfile')->destroy($id)){
$message="已删除";
}
return $message;
}
//批量删除
public function delall()
{
$status=0;
$message="删除失败";
$data = $this->request->param();
$allid = $data['id'];
$ids='';
foreach($allid as $k=>$value){
$ids[$k]=$value;
}
$num = count($allid);
if(model('Imgfile')->destroy($ids)){
$status=1;
$message="删除成功";
}
return ['status'=>$status, 'message'=> $message ,'num'=> $num];
}
//选择图片1-1
public function simple($tag_id=1)
{
$count=model('Imgfile')->where('tag_id',$tag_id)->count();
//$file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->paginate(14,false,['query' => request()->param()]);
$file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->select();
$this->assign([
'file'=>$file,
'count'=>$count
]);
return $this->fetch('imgfile/simple', ['tag_id' =>1]);
}
//选择图片1-1
public function more($tag_id=1)
{
$count=model('Imgfile')->where('tag_id',$tag_id)->count();
//$file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->paginate(14,false,['query' => request()->param()]);
$file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->select();
$this->assign([
'file'=>$file,
'count'=>$count
]);
return $this->fetch('imgfile/more', ['tag_id' =>1]);
}
}
~~~
- 心灵笔记
- tp5在编辑器一行一个添加信息
- 出库入库处理
- 出库
- 入库
- 后台控制器
- tp5加载更多-流加载
- 配件列表
- Parts.php
- add.html
- edit.html
- 图片管理
- controller
- 1.imgfile.php
- 2.imgfiletag.php
- view
- imgfile
- 1.index.html
- 2.show.html
- 3.simple.html
- 4.more.html
- 5.edit.html
- 6.deittag.html
- imgfiletag
- add.htm
- edit.htm
- model
- imgfile.php
- imgfiletag.php
- api
- upload.php
- js
- admin.js
- tp5整合百度编辑器多图上传
- 1.html代码
- 2.js代码
- 3.api代码
- 4.extend中的拓展代码
- tp5删除图片同时删除服务器图片
- 实用字段的的添加更新
- 根据时间戳获取未来几天星期几
- curl
- 城市按字母排版
- 聚合查询及渲染,处理产品首页
- 过滤字段
- 风控
- 查询id是否在数组里
- 判断更新还是新增操作
- tp5使用引入php文件