내가 Laravel 5.3을 사용하고 있는데 나는 직장 내에서 사용자의 파일을 제거하기 위해 노력하고있어 :Laravel는 수집
public function handle()
{
//Remove all files from a message
$this->files->map(function($file) {
$path = $file->getPath();
if(Storage::disk('s3')->exists($path))
{
Storage::disk('s3')->delete($path);
if(!Storage::disk('s3')->exists($path))
{
$attachment = File::find($file->id);
$attachment->delete();
}
}
});
}
을 그래서이 collections
을위한 노력에 하나 개의 모델 인스턴스를 변환합니다. 하지만 모델 인스턴스 one
을 전달하면 어떻게 작동합니까?
물론에 설명 된대로, 당신은 단지 확인하실 수 있습니다 경우 { $ this->'$ this-> files' '경우 (를 분명히 \ 데이터베이스 \ 웅변 \ 수집) instanceof를! ($ this-> 파일) files = collect ([$ this-> files ])); }' – mcklayin