【发布时间】:2021-03-04 17:22:12
【问题描述】:
在列表中我显示最新的主题,包括那些被删除的主题。
function latest()
{
return Topic::withTrashed()->latest();
}
为了显示单个主题,我有一个 Livewire 组件,其中传递了该主题。
class ShowTopic extends Component
{
public $topic;
public function mount(Topic $topic)
{
$this->topic = $topic;
}
public function render()
{
return view('livewire.show-topic', [
'topic' => $this->topic,
]);
}
}
但是当我转到已删除的单个主题时,它不会显示。如何在模型路由绑定上使用 withTrashed() 以显示带有我的 Livewire 组件的已删除记录?
【问题讨论】:
标签: laravel eloquent laravel-livewire