ThinkPHP5.1资源控制器Blog简单案例,使用路由,开启了强制路由限制,在postman上使用了接口调用,也是参考了官网的简单案例,实现了增删改查,再简单的必须熟练,效率才能提上去。
ThinkPHP5.1资源控制器Blog简单案例,使用路由,开启了强制路由限制,在postman上使用了接口调用,也是参考了官网的简单案例,实现了增删改查,再简单的必须熟练,效率才能提上去。
<?php
/*
* @Author: your name
* @Date: 2021-04-10 11:44:40
* @LastEditTime: 2021-04-10 11:57:19
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \thinkphp5.1.4\application\api\model\Blog.php
*/
namespace app\api\model;
use think\Model;
class Blog extends Model
{
/*
* 新增一条数据
*/
public static function listsBlog($params)
{
return self::where('id','gt',0)->select();
}
/*
* 新增一条数据
*/
public static function addBlog($data)
{
$blogModel = new Blog();
return $blogModel->save($data);
}
/*
* 更新一条数据
*/
public static function updateBlog($id, $data)
{
$blog = Blog::get($id);
if ($blog) {
return $blog->save($data);
} else {
return $blog;
}
}
/*
* 查询一条数据
*/
public static function findBlog($id)
{
return self::find($id);
}
/*
* 删除一条数据
*/
public static function deleteBlog($id)
{
$blog = Blog::get($id);
return $blog->delete($id);
}
}
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
转载注明:
感谢博主,喝杯咖啡~
感谢博主,喝杯咖啡~
还没有人发表评论