|
@@ -9,6 +9,11 @@ use Illuminate\Routing\Controller as BaseController;
|
|
|
use Illuminate\Support\Facades\Cookie;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Storage;
|
|
|
+use App\Models\BaseModel;
|
|
|
+use Ramsey\Uuid\Uuid;
|
|
|
+use Illuminate\Support\Facades\Mail;
|
|
|
+use App\Mail\NotifyEmail;
|
|
|
|
|
|
use App\Models\AppSession;
|
|
|
|
|
@@ -39,6 +44,18 @@ class Controller extends BaseController
|
|
|
view()->share('user', $this->user);
|
|
|
}
|
|
|
|
|
|
+ public function sendEmailNotification($details){
|
|
|
+ $to = $details['to'];
|
|
|
+ if(config('app.env') !== 'production'){
|
|
|
+ $to = [
|
|
|
+ ['email' => config('app.testEmailAddress'), 'name' => 'Test Email Address']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ Mail::to($to)->send(new NotifyEmail($details));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
public function callJava($endPoint, $data, $sessionKey)
|
|
|
{
|
|
|
$url = config('app.backendUrl') . $endPoint;
|
|
@@ -148,4 +165,27 @@ class Controller extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function storeFileAs(Request $request, $fileRef, $path){
|
|
|
+ $file = $request->file($fileRef);
|
|
|
+ if ($file) {
|
|
|
+ $uid = Uuid::uuid6();
|
|
|
+ $originalFileName = $file->getClientOriginalName();
|
|
|
+ $fileName = $uid . "." . $file->extension();
|
|
|
+ $tempPath = Storage::putFileAs($path, $file, $fileName);
|
|
|
+ return [
|
|
|
+ 'path' => $tempPath,
|
|
|
+ 'fileName' => $fileName,
|
|
|
+ 'url' => route('view-uploaded-file', $fileName),
|
|
|
+ 'orginalFileName' => $originalFileName
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function downloadFileByPath($file, $path){
|
|
|
+ return Storage::response($path . '/' . $file);
|
|
|
+ }
|
|
|
+ public function viewUploadedFile(Request $request, $file){
|
|
|
+ return $this->downloadFileByPath($file, BaseModel::FILE_PATH);
|
|
|
+ }
|
|
|
}
|