无论如何在控制器中检索随机 url 参数

Is there anyway of retrieving random url parameter in controller

每次开具新发票时,我都会使用 laravel notifiable 向特定用户发送电子邮件。

通过这封电子邮件,我将 url 和 link 发送到发票,如下所示:

public function toMail($notifiable)
{
    $url = url('/invoices/'.$this->id.'/edit');

    return (new MailMessage)
    ->line('The introduction to the notification.')
    ->action('Notification Action', url($url))
    ->line('Thank you for using our application!');
}

输出url = customer/invoices/6c081f60-d25a-4798-bf6e-bcc4924b1e53/edit

我的控制器:

public function edit($id)
{

    $invoice = InvoicesData::where('invoice_id', $id)->first();

    return view('customer.invoices.edit', compact('invoice'));


}

如何从我的控制器函数中的 url 中检索 'id' 参数?

我应该脱掉我的 url 还是有其他选择?

喜欢laravel用于web.php

Route::resource('customer/invoices', 'CustomerInvoiceController', ['names' 
=> [

    'index' => 'customer.invoices.index',
    'store' => 'customer.invoices.store',
    'edit' => 'customer.invoices.edit',

]]);

提前致谢!

如果这是完整的 url 则随机 ID 是第三个片段customer/invoices/6c081f60-d25a-4798-bf6e-bcc4924b1e53/edit。在 Laravel 你可以做...

$id = $request->segment(3);

$id = Request::segment(3);