我正在创建一个保姆预订系统。预订后24小时,我将向父母用户发送电子邮件以查看保姆。我想向父用户发送一个URL,以便他单击该URL时可以查看保姆。除URL之外,其他所有内容均有效。该网址必须在24小时内过期。我知道我必须在url中传递令牌,但是我该如何进行数据库设计呢?以及如何根据令牌使URL过期?
任何意见,将不胜感激
假设您有一个预订表,至少需要以下字段
ID, user_id, nanny_id, created_at
Run Code Online (Sandbox Code Playgroud)
或类似的名称,user_id“父母用户” 在哪里,而nanny_id指已预订的保姆。在这种情况下,该created_at字段可用于确定何时进行预订。您可以向父母发送特定的链接,包括booking_id
Route::get('/review/{booking_id}', ['uses' => 'BookingController@review', 'as' => 'booking.review']);
Run Code Online (Sandbox Code Playgroud)
然后在控制器内,您只需:
public function review($booking_id)
{
$booking = Booking::find($booking_id);
if (Carbon::now()->greaterThan($booking->created_at->addDay())) {
// the booking is more than 24 hours ago
return "sorry you cannot review anymore.";
}
return "Please review the Nanny";
}
Run Code Online (Sandbox Code Playgroud)
这样,您将不需要带有令牌等的额外表。当然,如果您需要更灵活的链接,则仅为可能具有不同到期时间的特定操作提供额外的表可能是有意义的。
| 归档时间: |
|
| 查看次数: |
1407 次 |
| 最近记录: |