1
我在UploadController
中有這個功能,用於取消上傳,我正在嘗試改進它。在這裏使用存儲庫,事件或服務提供者?
這個"File::delete..block"
在我的應用程序中存在兩次。例如從控制器中排除這個塊是否有意義?如果是的話,我應該用什麼,Repository
,Service Provider
或Event
?
public function postDelete(Request $request)
{
$filename = $request->input('filename');
$upload = Upload::where('filename',$filename)->where('accepted',0)->firstOrFail();
File::delete('img/uploads/'.$filename.'_o.jpg');
File::delete('img/uploads/'.$filename.'.jpg');
File::delete('img/uploads/'.$filename.'_zoom.jpg');
File::delete('img/uploads/'.$filename.'_tn.jpg');
File::delete('img/uploads/'.$filename.'_250.jpg');
File::delete('img/uploads/'.$filename.'_50.jpg');
$upload->delete();
Cache::forget('waiting_uploads');
$msg = 'upload has been deleted';
Mail::to('[email protected]')->send(new TextMail($msg));
return redirect('upload');
}