我的cakephp 3应用程序中有2个表 - 项目和颜色.一个Item也可以有多个Primary Colors和Secondary Colors.所以,我创建了2个联结表 - items_primary_colors和items_secondary_colors.两者都有相同的模式 - item_id和color_id(加入Items和Colors表)我不知道如何在TableModel中指定这些关系以及如何格式化表单数据以保存两种类型的颜色.我的ItemTable.php代码有 -
$this->belongsToMany('Colors', [
'foreignKey' => 'item_id',
'targetForeignKey' => 'color_id',
'joinTable' => 'items_primary_colors'
]);
$this->belongsToMany('Colors', [
'foreignKey' => 'item_id',
'targetForeignKey' => 'color_id',
'joinTable' => 'items_secondary_colors'
]);
Run Code Online (Sandbox Code Playgroud)
而且,我正在以这种方式格式化表单数据 -
[primary_colors] => Array
(
[_ids] => Array
(
[0] => 2
)
)
[secondary_colors] => Array
(
[_ids] => Array
(
[0] => 3
)
)
Run Code Online (Sandbox Code Playgroud)
它不起作用.我应该怎么处理这个?
我正在使用密码授予令牌为移动应用程序构建API .当用户尝试登录应用程序时,客户端会发送访问令牌请求.
用户可能没有使用发送到他的电子邮件的链接验证他的帐户.我希望为查询添加一个附加条件,并相应地提供错误响应.目前,由于Passport管理令牌部分,我无法直接执行.
怎么解决这个问题?如果用户帐户有任何问题,我如何潜入令牌请求并发送自定义响应?并继续发送令牌.