我正在使用Laravel 5.7。*和sluggable ^4.6。
在模型中:
namespace App;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
class Subscriber extends Model
{
use Sluggable;
public function sluggable()
{
return [
'slug' => [
'source' => 'value'
]
];
}
}
和表格:
和web.php(我测试了所有这些)
Route::get('/subscribers/{subscriberSlug}', 'Mails\SubscriberController@verified_mobile')->name('subscriber.verified_mobile');
或
Route::get('/subscribers/{slug}', 'Mails\SubscriberController@verified_mobile')->name('subscriber.verified_mobile');
或
Route::get('/subscribers/{subscriber}', 'Mails\SubscriberController@verified_mobile')->name('subscriber.verified_mobile');
并在控制器中:
public function verified_mobile(Subscriber $subscriber)
{
dd($subscriber);
}
并使用以下URL进行调用:
但是它返回了一个空对象,像这样:
对于所有其他类似的URL,它也会返回如下相同的结果:
我怎么了?