new deployer command
This commit is contained in:
@@ -45,16 +45,13 @@ final class AttachmentService
|
||||
$size = (int) Storage::disk($disk)->size($path);
|
||||
}
|
||||
|
||||
Attachment::query()->create($this->attachmentAttributes(
|
||||
ticket: $ticket,
|
||||
comment: $comment,
|
||||
userId: $userId,
|
||||
disk: $disk,
|
||||
path: $path,
|
||||
originalName: $originalName,
|
||||
mimeType: $mimeType,
|
||||
size: $size,
|
||||
));
|
||||
Attachment::query()->create($this->attachmentAttributes($ticket, $comment, $userId, [
|
||||
'disk' => $disk,
|
||||
'path' => $path,
|
||||
'original_name' => $originalName,
|
||||
'mime_type' => $mimeType,
|
||||
'size' => $size,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,29 +69,29 @@ final class AttachmentService
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function attachmentAttributes(Ticket $ticket, ?Comment $comment, int $userId, string $disk, string $path, string $originalName, string $mimeType, int $size): array
|
||||
private function attachmentAttributes(Ticket $ticket, ?Comment $comment, int $userId, array $file): array
|
||||
{
|
||||
$attributes = [
|
||||
'ticket_id' => $ticket->id,
|
||||
'comment_id' => $comment?->id,
|
||||
'user_id' => $userId,
|
||||
'disk' => $disk,
|
||||
'path' => $path,
|
||||
'original_name' => $originalName,
|
||||
'mime_type' => $mimeType,
|
||||
'size' => $size,
|
||||
'disk' => $file['disk'],
|
||||
'path' => $file['path'],
|
||||
'original_name' => $file['original_name'],
|
||||
'mime_type' => $file['mime_type'],
|
||||
'size' => $file['size'],
|
||||
];
|
||||
|
||||
if (Schema::hasColumn('helpdesk_attachments', 'extension')) {
|
||||
$attributes['extension'] = strtolower((string) pathinfo($originalName, PATHINFO_EXTENSION));
|
||||
$attributes['extension'] = strtolower((string) pathinfo($file['original_name'], PATHINFO_EXTENSION));
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('helpdesk_attachments', 'category')) {
|
||||
$attributes['category'] = $this->categoryFor($originalName, $mimeType);
|
||||
$attributes['category'] = $this->categoryFor($file['original_name'], $file['mime_type']);
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('helpdesk_attachments', 'checksum_sha256') && Storage::disk($disk)->exists($path)) {
|
||||
$stream = Storage::disk($disk)->readStream($path);
|
||||
if (Schema::hasColumn('helpdesk_attachments', 'checksum_sha256') && Storage::disk($file['disk'])->exists($file['path'])) {
|
||||
$stream = Storage::disk($file['disk'])->readStream($file['path']);
|
||||
|
||||
if (is_resource($stream)) {
|
||||
$context = hash_init('sha256');
|
||||
|
||||
Reference in New Issue
Block a user