~~~
<?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文件