从数据库中提取时,我得到id了字符串.
$alphabets = new Alphabet();
return $alphabets->pluck('name', 'id');
Run Code Online (Sandbox Code Playgroud)
产量
{
"1": "Apple",
"2": "Ball",
"3": "Cat"
}
Run Code Online (Sandbox Code Playgroud)
预期
{
1: "Apple",
2: "Ball",
3: "Cat"
}
Run Code Online (Sandbox Code Playgroud)
但是,当我扭转ID和name,
return $alphabets->pluck('id', 'name');
Run Code Online (Sandbox Code Playgroud)
我得到id为整数.
{
"Apple": 1,
"Ball": 2,
"Cat": 3
}
Run Code Online (Sandbox Code Playgroud)
我不确定幕后发生了什么.但是我如何获得整数ID?实际上,旧的flash会话因为1 vs "1"Form Collective 而没有设置值.
{!! Form::select('alphabet', $alphabets, null, ['class' => 'form-control', 'multiple' => true]) !!}
Run Code Online (Sandbox Code Playgroud) 我正在尝试获得redux-saga从服务返回的操作响应。这些是我的项目的一些片段。
// ACTION
const actions = {
LOAD_CURRENT_ACCOUNT: 'user/LOAD_CURRENT_ACCOUNT'
};
export const currentUser = () => ({
type: actions.LOAD_CURRENT_ACCOUNT
});
Run Code Online (Sandbox Code Playgroud)
// SERVICE
export async function currentAccount() {
try {
const url = config.endpoints.user;
const res = await http.get(url);
return res.data;
} catch (err) {
if (err.response && err.response.data) {
notification.warning({
message: err.response.data.code,
description: err.response.data.message
});
}
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
// SAGA
export function* LOAD_CURRENT_ACCOUNT() {
const res = yield call(currentAccount);
if (res) {
yield put({
type: actions.SET_STATE, …Run Code Online (Sandbox Code Playgroud) 我查看了 SQL Server 文档,但没有找到类似 JSON 聚合的内容。这是我的表的结构。
| Column Name | Type | Nullable | Properties | Description |
| ------------------- | ------------------ | -------- | ---------- | ----------- |
| employee_id | INT(4) | NO | | |
| first_name | NVARCHAR(100) | NO | | |
| last_name | NVARCHAR(100) | NO | | |
| department_id | INT(4) | NO | | |
| date | DATETIMEOFFSET(10) | NO | | |
Run Code Online (Sandbox Code Playgroud)
我期待的是:
{
department_id: 1,
count: 2, …Run Code Online (Sandbox Code Playgroud) 在web.php中,随着发出HTTP请求的子域类型,我在中间件中切换了Postgres模式。这条路:
Route::group(
[
'domain' => '{tenant}.' . config('app.url'),
'middleware' => 'select-schema'
],
function () {
$this->get('/', 'HomeController@index')->middleware('auth');
}
);
Run Code Online (Sandbox Code Playgroud)
在选择模式中间件中,我这样做。这可以正常工作。(不用担心)
DB::select('SET search_path TO ' . {tenant});
Run Code Online (Sandbox Code Playgroud)
我的主要问题是:migrations对于public方案和任何其他方案,我都有所不同individual tenant。在individual tenant我有users桌子。一旦我登录,就会弹出此错误。
SQLSTATE [42P01]:未定义表:7错误:关系“用户”不存在
主要问题是
$this->get('/', 'HomeController@index')->middleware('auth');
Run Code Online (Sandbox Code Playgroud)
该模型运行良好,但中间件auth先执行 select-schema
我该如何订购? select-schema然后auth
laravel ×2
php ×2
forms ×1
javascript ×1
json ×1
middleware ×1
multi-tenant ×1
pluck ×1
postgresql ×1
reactjs ×1
redux-saga ×1
sql ×1
sql-server ×1
t-sql ×1