// Remove the contract file from the private disk if one exists.
if($staff->contract_path){
Storage::delete($staff->contract_path);
}
$staff->delete();
returnback()->with('success','Staff member deleted.');
}
/**
* Download the staff member's contract PDF.
*
* This is the only way to access private files. The route is
* inside the auth group, so guests can't reach it. Storage::download()
* reads the file from the private disk and streams it to the browser
* as a download — no public URL is ever created.
*/
publicfunctiondownloadContract(Staff$staff)
{
// If there's no contract, show a 404 instead of an error
if(!$staff->contract_path){
abort(404);
}
returnStorage::download($staff->contract_path);// It returns a download response. Instead of showing a web page, the browser gets the file streamed to it and opens a “Save as” dialog (or downloads it automatically, depending on browser settings).