hoàn thiện upload và global search
This commit is contained in:
@@ -10,10 +10,12 @@ use App\Filament\Resources\Feedback\Schemas\FeedbackForm;
|
||||
use App\Filament\Resources\Feedback\Tables\FeedbackTable;
|
||||
use App\Models\Feedback;
|
||||
use BackedEnum;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class FeedbackResource extends Resource
|
||||
{
|
||||
@@ -25,6 +27,8 @@ class FeedbackResource extends Resource
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static function getPluralLabel(): ?string
|
||||
{
|
||||
return __('app.resource_feedbacks');
|
||||
@@ -60,4 +64,34 @@ class FeedbackResource extends Resource
|
||||
'edit' => EditFeedback::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
// GlobalSearch customization
|
||||
public static function getGlobalSearchEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getGlobalSearchEloquentQuery()
|
||||
->with(['customer', 'customerProduct.product', 'currentDepartment']);
|
||||
}
|
||||
|
||||
public static function modifyGlobalSearchQuery(Builder $query, string $search): void
|
||||
{
|
||||
$query->where('title', 'like', "%{$search}%")
|
||||
->orWhere('content', 'like', "%{$search}%")
|
||||
->orWhereHas('customer', fn ($q) => $q->where('name', 'like', "%{$search}%"));
|
||||
}
|
||||
|
||||
public static function getGlobalSearchResultDetails(Model $record): array
|
||||
{
|
||||
return [
|
||||
__('app.widget_customer') => $record->customer?->name ?? '-',
|
||||
__('app.product') => $record->customerProduct?->product?->name ?? __('app.general'),
|
||||
__('app.blade_status') => match ($record->status) {
|
||||
'pending' => __('app.status_pending'),
|
||||
'processing' => __('app.status_processing'),
|
||||
'resolved' => __('app.status_resolved'),
|
||||
'closed' => __('app.status_closed'),
|
||||
default => $record->status,
|
||||
},
|
||||
__('app.department') => $record->currentDepartment?->name ?? '-',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ class EditFeedback extends EditRecord
|
||||
->multiple()
|
||||
->disk('public')
|
||||
->directory('feedback-attachments')
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'application/pdf', 'video/mp4', 'video/quicktime'])
|
||||
->maxSize(51200) // 50MB in KB
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
|
||||
@@ -77,6 +77,8 @@ class InteractionsRelationManager extends RelationManager
|
||||
->multiple()
|
||||
->disk('public')
|
||||
->directory('feedback-attachments')
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'application/pdf', 'video/mp4', 'video/quicktime'])
|
||||
->maxSize(51200) // 50MB in KB
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -197,6 +197,8 @@ class FeedbackForm
|
||||
->multiple()
|
||||
->disk('public')
|
||||
->directory('feedback-attachments')
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'application/pdf', 'video/mp4', 'video/quicktime'])
|
||||
->maxSize(51200) // 50MB in KB
|
||||
->columnSpan(1),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Reference in New Issue
Block a user