| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Hooks\Handlers; |
| 4 |
|
| 5 |
use FluentSupport\App\Models\Conversation; |
| 6 |
use FluentSupport\App\Services\Includes\UploadService; |
| 7 |
|
| 8 |
class FileUploadHandler |
| 9 |
{ |
| 10 |
public function init() |
| 11 |
{ |
| 12 |
|
| 13 |
} |
| 14 |
|
| 15 |
private function updateFileInfo($file, $uploadInfo) |
| 16 |
{ |
| 17 |
$file->file_path = $uploadInfo['file_path'] ?? $uploadInfo['path'] ?? null; |
| 18 |
$file->full_url = $uploadInfo['url'] ?? $uploadInfo['full_url'] ?? null; |
| 19 |
$file->title = $uploadInfo['name'] ?? $file->title; |
| 20 |
$file->driver = $uploadInfo['driver'] ?? 'local'; |
| 21 |
$file->status = 'active'; |
| 22 |
$file->save(); |
| 23 |
|
| 24 |
return true; |
| 25 |
} |
| 26 |
|
| 27 |
public static function getFileUploadErrorNoteMessage($driver = 'local', $type = 'response') |
| 28 |
{ |
| 29 |
$errorMessages = [ |
| 30 |
'google_drive_settings' => 'Google Drive', |
| 31 |
'dropbox_settings' => 'Dropbox', |
| 32 |
'local' => 'Local Server', |
| 33 |
]; |
| 34 |
|
| 35 |
if ('response' == $type) { |
| 36 |
$noteMessage = 'Attached file in this conversation is failed to upload to ' . $errorMessages[$driver] . ', Please check your'; |
| 37 |
} else { |
| 38 |
$noteMessage = 'Attached file during creation this ticket is failed to upload to ' . $errorMessages[$driver] . ', Please check your'; |
| 39 |
} |
| 40 |
|
| 41 |
if ('local' == $driver) { |
| 42 |
$noteMessage .= ' upload folder permission is writeable or not'; |
| 43 |
} else { |
| 44 |
$noteMessage .= ' ' . $errorMessages[$driver] . ' settings'; |
| 45 |
} |
| 46 |
|
| 47 |
return $noteMessage; |
| 48 |
} |
| 49 |
} |
| 50 |
|