我需要获取以所需字母开头的所有文件,我正在尝试使用->where过滤器添加'like'为运算符但通配符不起作用.
$files = File::files(storage_path($id_files));
$files = collect($files);
$files->transform(function ($item, $key){
$item->public_filename = $item->getFilename();
return $item;
});
Run Code Online (Sandbox Code Playgroud)
这是我们的目标数据,我需要创建一个public_filename应用过滤器的字段.我们的文件(dd($files)):
Collection {#503 ?
#items: array:3 [?
0 => SplFileInfo {#525 ?
-relativePath: ""
-relativePathname: "atxt.txt"
path: "/home/vagrant/Code/project/storage/app/uploads/general"
filename: "atxt.txt"
basename: "atxt.txt"
pathname: "/home/vagrant/Code/project/storage/app/uploads/general/atxt.txt"
extension: "txt"
realPath: "/home/vagrant/Code/project/storage/app/uploads/general/atxt.txt"
aTime: 2017-09-29 09:51:17
mTime: 2017-09-27 14:39:11
cTime: 2017-09-27 14:39:11
inode: 32833
size: 3
perms: 0100777
owner: 1000
group: 1000
type: "file"
writable: true
readable: true
executable: true
file: …Run Code Online (Sandbox Code Playgroud)