Laravel 8: 如何在session中设置ID
Laravel 8: how to set ID in session
我正在尝试将我的业务中的 ID table 设置为会话中的 business_id
Illuminate\Support\Collection {#388 ▼
#items: array:1 [▼
0 => {#1265 ▼
+"id": 1
+"user_id": 1
+"business_name": "my company"
+"type_of_business": "Financial Services"
+"country": "Canada"
+"business_currency": "USD"
+"type_of_organization": "Partnership"
+"is_personal": 1
+"created_at": "2021-02-05 02:18:33"
+"updated_at": "2021-02-09 10:52:34"
+"is_deleted": 0
+"deleted_at": null
}
]
}
例如,我想在会话中将“id”设置为“business_id”
将此集合存储在一个变量中,假设您将其保存为 $business
。
Illuminate\Support\Collection {#388 ▼
#items: array:1 [▼
0 => {#1265 ▼
+"id": 1
+"user_id": 1
+"business_name": "my company"
+"type_of_business": "Financial Services"
+"country": "Canada"
+"business_currency": "USD"
+"type_of_organization": "Partnership"
+"is_personal": 1
+"created_at": "2021-02-05 02:18:33"
+"updated_at": "2021-02-09 10:52:34"
+"is_deleted": 0
+"deleted_at": null
}
]
}
\Session::set('business_id', $business->id); //this line of code is to store id as
//session
要获取变量,您需要使用...
\Session::get('business_id');
希望这会有所帮助。
我正在尝试将我的业务中的 ID table 设置为会话中的 business_id
Illuminate\Support\Collection {#388 ▼
#items: array:1 [▼
0 => {#1265 ▼
+"id": 1
+"user_id": 1
+"business_name": "my company"
+"type_of_business": "Financial Services"
+"country": "Canada"
+"business_currency": "USD"
+"type_of_organization": "Partnership"
+"is_personal": 1
+"created_at": "2021-02-05 02:18:33"
+"updated_at": "2021-02-09 10:52:34"
+"is_deleted": 0
+"deleted_at": null
}
]
}
例如,我想在会话中将“id”设置为“business_id”
将此集合存储在一个变量中,假设您将其保存为 $business
。
Illuminate\Support\Collection {#388 ▼
#items: array:1 [▼
0 => {#1265 ▼
+"id": 1
+"user_id": 1
+"business_name": "my company"
+"type_of_business": "Financial Services"
+"country": "Canada"
+"business_currency": "USD"
+"type_of_organization": "Partnership"
+"is_personal": 1
+"created_at": "2021-02-05 02:18:33"
+"updated_at": "2021-02-09 10:52:34"
+"is_deleted": 0
+"deleted_at": null
}
]
}
\Session::set('business_id', $business->id); //this line of code is to store id as
//session
要获取变量,您需要使用...
\Session::get('business_id');
希望这会有所帮助。