public function index()
{
$genres = Genres::all();
return view('/admin/genres/index')->with('genres', Genres::orderBy('id', 'DESC')->get());
}
我想调出 index.blade 中的数据,其数据是从数据库中检索的。但是当它们根据 huru 'a' 的首字母/序列出现时。
最佳答案
你可以按名字排序
$geners = Genres::orderBy('name')->get();
return view('admin/genres/index', compact('geners'));
关于php - 如何根据首字母对数据进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56522119/