我如何在 laravel 中用 eloquent 从数据库中检索 created_data?,我使用的是属于多个关系,我想显示借书数据和借阅日期,我已成功显示借书数据,但我无法获取 created_at 数据来自数据库中另一个名为 borrow_history 的表书本.phppublic function borrowed(){ return $this->belongsToMany(User::class, 'borrow_history') ->withTimestamps();}用户.phppublic function borrow(){ return $this->belongsToMany(Book::class, 'borrow_history') ->withTimestamps();}这是我当前的 HomeController.php 索引public function index(){ $books = auth()->user()->borrow; return view('home', [ 'books' => $books, ]);}我想在 home.blade.php 显示 created_at 数据@foreach($borrow_history as $borrow) <p> <i class="material-icons">date_range</i> Borrow_date : {{ ???? }} </p>@endforeach谁能帮我?
- 1 回答
- 0 关注
- 104 浏览
添加回答
举报
0/150
提交
取消