【发布时间】:2017-03-11 10:11:44
【问题描述】:
我正在使用 Laravel 5.3,我正在尝试从作业中的用户删除文件::
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 模型实例时,如何让它工作呢?
【问题讨论】:
标签: php collections laravel-5.3