hoàn thiện upload và global search
This commit is contained in:
@@ -16,6 +16,8 @@ use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductResource extends Resource
|
||||
{
|
||||
@@ -27,6 +29,8 @@ class ProductResource extends Resource
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function getPluralLabel(): ?string
|
||||
{
|
||||
return __('app.resource_products');
|
||||
@@ -64,4 +68,24 @@ class ProductResource extends Resource
|
||||
'edit' => EditProduct::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
// GlobalSearch customization
|
||||
public static function modifyGlobalSearchQuery(Builder $query, string $search): void
|
||||
{
|
||||
$query->where('name', 'like', "%{$search}%")
|
||||
->orWhere('description', 'like', "%{$search}%");
|
||||
}
|
||||
|
||||
public static function getGlobalSearchResultDetails(Model $record): array
|
||||
{
|
||||
return [
|
||||
__('app.description') => $record->description ? \Illuminate\Support\Str::limit($record->description, 50) : '-',
|
||||
__('app.blade_status') => match ($record->status) {
|
||||
'active' => __('app.status_active'),
|
||||
'inactive' => __('app.status_inactive'),
|
||||
'sold_out' => __('app.status_sold_out'),
|
||||
default => $record->status,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user