function store(DocumentAddRequest $request){
$modeldata = $this->normalizeFormData($request->validated());
if( array_key_exists("file", $modeldata) ){
//move uploaded file from temp directory to destination directory
$fileInfo = $this->moveUploadedFiles($modeldata['file'], "file");
$modeldata['file'] = $fileInfo['filepath'];
}
//save Document record
$record = Document::create($modeldata);
$rec_id = $record->id;
$client = Clients::find($request->client_id);
$email = $client->email;
try{
$subject = "Document Report";
$message = "This is your Document Report:\n"; // Add a new line // Add record data
$message = '<a href="' . $record->file . '" download><button>Download</button></a>'; // Add record data
// Add more record data as needed
$receiver = $email;
$this->sendRecordActionMail($receiver, $subject, $message);
}
catch(Exception $ex){
throw $ex;
}
return $this->redirect("document", "Record added successfully");
}
/**
this is how the file appeared to mailbox…
Download