亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

產(chǎn)品縮略圖模塊

オリジナル 2019-04-27 15:12:29 302
サマリー:<?php /**  * Created by PhpStorm.  * User: Jason  * Date: 2019/4/27  * Time: 13:59  */ namespace app\admin\controller; u
<?php
/**
 * Created by PhpStorm.
 * User: Jason
 * Date: 2019/4/27
 * Time: 13:59
 */

namespace app\admin\controller;

use app\admin\controller\Common;
use app\admin\model\ProductModel;
use app\admin\model\ProductPicModel;
use think\facade\Request;
use think\facade\Session;

class ProductPic extends Common
{
    // 渲染產(chǎn)品縮略圖列表
    public function index()
    {
        // 獲取縮略圖信息
        $prodcuts = ProductPicModel::order('id','desc')->paginate(6);
        // 模板賦值
        $this->assign('products',$prodcuts);
        // 渲染模板
        return $this->fetch();
    }

    // 添加產(chǎn)品縮略圖
    public function add()
    {
        // 查詢所有產(chǎn)品數(shù)據(jù)
        $products = ProductModel::field('id,title')->all();
        // 模板賦值
        $this->assign('products',$products);
        // 渲染模板
        return $this->fetch();
    }

    // 圖片上傳操作
    public function upload()
    {
        // 獲取圖片信息
        $file = Request::file('file');
        // 驗(yàn)證并移動(dòng)圖片
        if($info = $file->validate(['ext'=>'jpg,jpeg,png,gif'])->move('upload'))
        {
            $filePath = '/upload/'.$info->getSaveName();
            return json([1,'上傳成功','data'=>$filePath]);
        }

        return $info->getError();
    }

    // 產(chǎn)品縮略圖添加操作
    public function DoAdd()
    {
        // 獲取提交數(shù)據(jù)
        $data = Request::param();
        $data['username'] = Session::get('username');
        $data['time'] = time();

        $ins = ProductPicModel::create($data);
        if($ins) {
            return ['code'=>1,'msg'=>'產(chǎn)品縮略圖添加成功'];
        }

        return ['code'=>0,'msg'=>'產(chǎn)品縮略圖添加失敗'];
    }


    // 刪除操作
    public function DoDel()
    {
        // 獲取要?jiǎng)h除的ID
        $pid = Request::param('id');

        // 進(jìn)行軟刪除操作
        $del = ProductPicModel::destroy($pid);
        // 刪除狀態(tài)
        if($del) {
            return ['code'=>1,'msg'=>'數(shù)據(jù)刪除成功'];
        }

        return ['code'=>0,'msg'=>'數(shù)據(jù)刪除失敗'];
    }
}


添削の先生:查無此人添削時(shí)間:2019-04-27 17:28:22
先生のまとめ:又看到你了,今天完成的比較多,繼續(xù)加油。

手記を発表する

人気のある見出し語