them log, chinh upload
This commit is contained in:
@@ -49,6 +49,10 @@ class CreateFeedback extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($feedback->attachments()->where('path', $path)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$feedback->attachments()->create([
|
||||
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
||||
'user_id' => auth()->id(),
|
||||
@@ -56,9 +60,27 @@ class CreateFeedback extends CreateRecord
|
||||
'path' => $path,
|
||||
'disk' => 'public',
|
||||
'collection' => $this->pendingCollection,
|
||||
'mime_type' => $disk->mimeType($path),
|
||||
'size' => $disk->size($path),
|
||||
'mime_type' => $this->safeMimeType($disk, $path),
|
||||
'size' => $this->safeFileSize($disk, $path),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function safeMimeType($disk, string $path): ?string
|
||||
{
|
||||
try {
|
||||
return $disk->mimeType($path);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function safeFileSize($disk, string $path): ?int
|
||||
{
|
||||
try {
|
||||
return $disk->size($path);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,10 @@ class EditFeedback extends EditRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($feedback->attachments()->where('path', $path)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$feedback->attachments()->create([
|
||||
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
||||
'user_id' => $sender->id,
|
||||
@@ -97,8 +101,8 @@ class EditFeedback extends EditRecord
|
||||
'path' => $path,
|
||||
'disk' => 'public',
|
||||
'collection' => 'general',
|
||||
'mime_type' => $disk->mimeType($path),
|
||||
'size' => $disk->size($path),
|
||||
'mime_type' => $this->safeMimeType($disk, $path),
|
||||
'size' => $this->safeFileSize($disk, $path),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -194,6 +198,10 @@ class EditFeedback extends EditRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($feedback->attachments()->where('path', $path)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$feedback->attachments()->create([
|
||||
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
||||
'user_id' => auth()->id(),
|
||||
@@ -201,12 +209,30 @@ class EditFeedback extends EditRecord
|
||||
'path' => $path,
|
||||
'disk' => 'public',
|
||||
'collection' => $this->pendingCollection,
|
||||
'mime_type' => $disk->mimeType($path),
|
||||
'size' => $disk->size($path),
|
||||
'mime_type' => $this->safeMimeType($disk, $path),
|
||||
'size' => $this->safeFileSize($disk, $path),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function safeMimeType($disk, string $path): ?string
|
||||
{
|
||||
try {
|
||||
return $disk->mimeType($path);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function safeFileSize($disk, string $path): ?int
|
||||
{
|
||||
try {
|
||||
return $disk->size($path);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
$data['is_general'] = $data['customer_product_id'] === null;
|
||||
|
||||
@@ -27,7 +27,10 @@ class InteractionsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'interactions';
|
||||
|
||||
protected static ?string $title = 'feedback.interaction_history';
|
||||
public static function getTitle(\Illuminate\Database\Eloquent\Model $ownerRecord, string $pageClass): string
|
||||
{
|
||||
return __('feedback.interaction_history');
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -211,6 +214,10 @@ class InteractionsRelationManager extends RelationManager
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($record->attachments()->where('path', $path)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$record->attachments()->create([
|
||||
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
||||
'feedback_id' => $record->feedback_id,
|
||||
@@ -219,8 +226,8 @@ class InteractionsRelationManager extends RelationManager
|
||||
'path' => $path,
|
||||
'disk' => 'public',
|
||||
'collection' => 'general',
|
||||
'mime_type' => $disk->mimeType($path),
|
||||
'size' => $disk->size($path),
|
||||
'mime_type' => $this->safeMimeType($disk, $path),
|
||||
'size' => $this->safeFileSize($disk, $path),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -262,4 +269,22 @@ class InteractionsRelationManager extends RelationManager
|
||||
throw new \Filament\Exceptions\SilentActionException;
|
||||
}
|
||||
}
|
||||
|
||||
protected function safeMimeType($disk, string $path): ?string
|
||||
{
|
||||
try {
|
||||
return $disk->mimeType($path);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function safeFileSize($disk, string $path): ?int
|
||||
{
|
||||
try {
|
||||
return $disk->size($path);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user