AdminForumController.php 3.5 KB
<?php
/**
 * 论坛报名
 * Author : xiaojie
 * DateTime: 2018/12/03 10:13
 */
namespace app\portal\controller;

use app\portal\model\ForumModel;
use cmf\controller\AdminBaseController;

/**
 * Class AdminForumController
 * @package app\portal\controller
 * @adminMenuRoot(
 *     'name'   =>'论坛报名',
 *     'action' =>'default',
 *     'parent' =>'',
 *     'display'=> true,
 *     'order'  => 30,
 *     'icon'   =>'th',
 *     'remark' =>'论坛报名'
 * )
 */

class AdminForumController extends AdminBaseController
{

    /**
     * 论坛报名
     * @adminMenu(
     *     'name'   => '论坛报名',
     *     'parent' => 'portal/AdminForum/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '论坛报名',
     *     'param'  => ''
     * )
     */
    public function index()
    {
        $forumModel = new ForumModel();
        $param = $this->request->param();
        $map = $this->search($param,'create_time','name|mobile|company');
        $list = $forumModel
            ->where($map)
            ->order('id DESC')
            ->paginate(30);

        $this->assign('list',$list);
        $this->assign('page',$list->render());
        return $this->fetch();
    }

    /**
     * 编辑论坛报名
     * @adminMenu(
     *     'name'   => '编辑论坛报名',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑论坛报名',
     *     'param'  => ''
     * )
     */
    public function edit()
    {
        $forumModel = new ForumModel();
        $id = $this->request->param('id','','intval');
        $info = $forumModel->where('id',$id)->find();

        $this->assign('info',$info);
        return $this->fetch();
    }

    /**
     * 编辑论坛报名提交
     * @adminMenu(
     *     'name'   => '编辑论坛报名提交',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '编辑论坛报名提交',
     *     'param'  => ''
     * )
     */
    public function editPost()
    {
        $forumModel = new ForumModel();
        $param = $this->request->param();
        $res = $forumModel->isUpdate(true)->save($param);
        if($res){
            $this->success('保存成功');
        }
        $this->error('请稍后重试');
    }

    /**
     * 删除
     * @adminMenu(
     *     'name'   => '删除',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '删除',
     *     'param'  => ''
     * )
     */
    public function delete()
    {
        $forumModel = new ForumModel();
        $res = $this->del($forumModel);
        if($res){
            $this->success('删除成功');
        }
        $this->error('请稍后重试');
    }

    /**
     * 参展登记导出
     */
    public function export()
    {
        $forumModel = new ForumModel();
        $data = $forumModel
            ->field('name,mobile,email,company,post,create_time')
            ->select()->each(function ($item){
                $item['create_time'] = date('Y-m-d',$item['create_time']);
            })->toArray();
        $this->exportExcel(array('联系人','手机号','邮箱','企业名称','职务','申请时间'), $data, '论坛报名', './', true);
    }

}