我正在使用Laravel 8建立一个个人博客, 其中的文章是由
.md
文件显示的(没有数据库).一切工作都很完美, 但我正在努力将这些
.md
文件按
modified date
或
creation date
进行排序.文件被放置在
storage
文件夹中
目前的代码。
// Getting files from storage:
$files = Storage::disk('articles')->allFiles();
$articles = [];
foreach ($files as $file) {
$storage = Storage::disk('articles')->get($file);
array_push($articles, $storage);
$collection = collect($articles);
$array = collect($articles);
$articles = $this->paginate($array);
return view('pages.home', compact('articles'));
我试着用filemtime()
函数来获取文件的详细信息,但我得到了以下错误。
$filePath = Storage::path($file);
$fileDate = filemtime($filePath);
dd($fileDate);
ErrorException
filemtime(): stat failed for C:\my-project\storage\app\article-file.md
stat
函数返回同样的错误。
存储器被链接,文件存在,它返回正确的路径......
我没有主意了...