yijia-webman/app/controller/CategoryController.php

36 lines
732 B
PHP

<?php
namespace app\controller;
use support\Request;
use app\model\Category;
class CategoryController
{
public function index(Request $request)
{
return view('category/index');
}
public function add(Request $request)
{
$method = $request->method();
if($method == 'POST')
{
$name = $request->post('name');
$categoryModel = new Category;
$categoryModel->save(['name' => $name]);
return json(['code' => 0, 'msg' => 'ok']);
}
return view('category/add');
}
public function apiGetList()
{
$list = Category::getList();
return json(['code' => 0, 'msg' => 'ok', 'list' => $list]);
}
}