项目里边多个数据库,dingo api开发怎么指定数据库?
别人遗留下来的项目,二次开发,里边有两个数据库,现在是在指定的数据库 mysql_wx 上重构,
YtUser model已经指定了数据库:
protected $connection = 'mysql_wx'; //指定数据库名
protected $table = 'yt_user'; //表名
路由
$api->get('me', 'AuthController@me');
//获取某个用户资料
$api->get('ytusers/{id}', 'YtUserController@show');
控制器
//获取用户资料
public function me()
{
return response()->json(auth('api')->user());
}
//指定用户
public function show($id)
{
$ytuser = YtUser::find($id);
return $this->response->item($ytuser, new YtUserTransformer());
}
现在API提示:
"message": "SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from `users` where `id` = 300812 limit 1)",
"code": 1045,
"status_code": 500,
请问大家在哪里dingo api里边指定某个数据库,谢谢大家!
推荐文章: