404_k/k_laravel_creator
v0.3
2017-07-25 15:20 UTC
Requires
- php: >=5.5.9
- laravel/framework: >=5.2.0
This package is not auto-updated.
Last update: 2024-09-14 19:20:13 UTC
README
希望这能帮助您快速构建API
说明
基于Laravel5.2,提供便捷的数据库和API接口的生产
安装
git clone git@github.com:mzkmzk/K_Laravel_Creator_Demo.git
composer install
chmod -R 777 storage/framework/ storage/logs bootstrap/cache
cp .env.example .env //配置.env
php artisan key:generate
php artisan make:k_command
rm -rf .git
使用
设置实体
//in app/Entities/Creator_User_Entity.php use K_Laravel_Creator\Entities\Base_Entity; <php? class Creator_User_Entity extends Base_Entity{ public static $entity = [ "User" => "用户" ]; // if has on to many entity public static $has_many = ['Creator_Activity']; /** * set_attribute 参数 */ public static function get_attribute(){ $attribute = array(); //wechat_id 为属性名 微信ID为字段说明 string 为该字段的类型, 可选类型有 "id" , "string" , "date_time" "url","int" $attribute['wechat_id'] = parent::set_attribute("微信ID","string"); $attribute['login_sum'] = parent::set_attribute("登陆次数","int"); $attribute['visit_password'] = parent::set_attribute("访问密码","string"); $attribute['sina_uid'] = parent::set_attribute("新浪id","string"); $attribute['sina_access_token'] = parent::set_attribute("新浪密钥","string"); return array_merge(parent::get_attribute(),$attribute); } }
将实体添加到配置
在/config/creator.php
<?php return [ 'entities' => [ 'Creator_User' ] ];
创建者代码和数据库表
php artisan make:k_command
结果
数据库表
API
插入
http://url/v1/Creator_User_Controller/query?id=161
{
"result": true,
"data": [
{
"updated_at": "2017-06-02 07:53:32",
"created_at": "2017-06-02 07:53:32",
"id": 161,
"patient_name": "11111",
"creator_activity": []
}
]
}
更新
http://inner.journey.404mzk.com/v1/Creator_User_Controller/update?id=161&wechat_id=1
{
"result": true
}
查询
http://url/v1/Creator_User_Controller/query?id=161
{
"total": 1,
"per_page": 15,
"current_page": 1,
"last_page": 1,
"next_page_url": null,
"prev_page_url": null,
"from": 1,
"to": 1,
"data": [
{
"id": 161,
"wechat_id": 1,
...
"creator_activity": [
{
"id": 337,
...
},
{
"id": 338,
...
}
]
}
]
}
删除
http://inner.journey.404mzk.com/v1/Creator_User_Controller/delete?id=161
{
"result": true
}
