ThinkPHP5.1资源控制器Blog简单案例,使用路由,开启了强制路由限制,在postman上使用了接口调用,也是参考了官网的简单案例,实现了增删改查,再简单的必须熟练,效率才能提上去。
ThinkPHP5.1资源控制器Blog简单案例,使用路由,开启了强制路由限制,在postman上使用了接口调用,也是参考了官网的简单案例,实现了增删改查,再简单的必须熟练,效率才能提上去。
<?php
/*
* @Author: chambers
* @Date: 2021-04-10 11:36:20
* @LastEditTime: 2021-04-21 17:43:34
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \thinkphp5.1.4\application\api\services\Blogs.php
*/
namespace app\api\services;
use app\api\model\Blog;
class Blogs
{
/**
* 资源列表
*
* @return \think\Response
*/
public function lists()
{
$list = (new Blog())->listsBlog([]);
return $list;
}
/**
* 创建资源
*
* @return \think\Response
*/
public static function create($data)
{
$result = Blog::addBlog($data);
return $result;
}
/**
* 保存更新的资源
*
* @param array $post
* @return \think\Response
*/
public static function save($id, $data)
{
$result = Blog::updateBlog($id, $data);
return $result;
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public static function read($id)
{
$result = (new Blog())->findBlog($id);
return $result;
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public static function delete($id)
{
$result = Blog::deleteBlog($id);
return $result;
}
}
?>
https://www.fxzbcn.com/html/thinkphp5/thinkphp51ziyuankongzhiqiBlogjiandananlizhipostman.html
https://www.fxzbcn.com/html/thinkphp5/thinkphp51ziyuankongzhiqiBlogjiandananlizhikongzhiqi.html
https://www.fxzbcn.com/html/thinkphp5/thinkphp51ziyuankongzhiqiBlogjiandananlizhifuwucengfangfa.html
https://www.fxzbcn.com/html/thinkphp5/thinkphp51ziyuankongzhiqiBlogjiandananlizhimoxingfangfa.html
转载注明:
感谢博主,喝杯咖啡~
感谢博主,喝杯咖啡~
还没有人发表评论