如何从插入数据库表的最近记录中检索数据



我正试图从放入表中的数据中显示一些信息。但结果是,尽管努力显示添加到该表中的最新记录的信息,但仅显示第一个记录的信息。

我会感谢你的帮助。。。

这是我的刀片页面中的代码

@if(!empty(Auth::user()->credo->money[0]->orderBy('updated_at','ASC')->get('is_payed')) == 1 )
<h4>You are eligible. <br>BMFA thanks you for the corcern.<hr/><span style="font-size:12px"> 
You refund is {{ Auth::user()->credo->money[0]->amount }}$</span>
</h4>
@endif

我的控制器

public function index()
{
$Users = User::all();
$Credos = Credos::all();
$MoneyP = MoneyP::all();
$context = [
'Credos' => $Credos,
'MoneyP' => $MoneyP,
'Users' => $Users,
];
return view('/')->with($context);
}

$results = Auth::user()->credo->money[0]->orderBy('updated_at','ASC')->get();
@foreach ($results as $result)
@if($result->is_payed == 1)
<h4>You are eligible. <br>BMFA thanks you for the corcern.<hr/><span style="font-size:12px">
You refund is {{ Auth::user()->credo->money[0]->amount }}$</span>
</h4>
@endif
@endforeach

最新更新