diff --git a/app/Filament/Resources/ImportResource.php b/app/Filament/Resources/ImportResource.php index d85e81d..81daaea 100644 --- a/app/Filament/Resources/ImportResource.php +++ b/app/Filament/Resources/ImportResource.php @@ -80,8 +80,8 @@ public static function table(Table $table): Table ->label(__('import.columns.processed')) ->searchable(), Tables\Columns\TextColumn::make('points_count') - ->counts('points') - ->label(__('common.points_count')), + ->counts('points') + ->label(__('common.points_count')), Tables\Columns\TextColumn::make('error_rows') ->label(__('import.columns.failed')), @@ -129,13 +129,13 @@ public static function table(Table $table): Table ->label(__('imports.remove_points')) ->default(false), ])->action(function (Collection $records, array $data) { - $records->each(function (Import $record) use ($data) { - if ($data['remove_points']) { - $record->points()->delete(); - } - $record->delete(); - }); - }), + $records->each(function (Import $record) use ($data) { + if ($data['remove_points']) { + $record->points()->delete(); + } + $record->delete(); + }); + }), ]), ]); } diff --git a/app/Filament/Resources/PointResource.php b/app/Filament/Resources/PointResource.php index 2757689..b891bc0 100644 --- a/app/Filament/Resources/PointResource.php +++ b/app/Filament/Resources/PointResource.php @@ -211,6 +211,7 @@ public static function getColumns() ->label(__('map_points.id')) ->sortable() ->searchable(), + TextColumn::make('serviceType.name') ->label(__('map_points.point_type')), @@ -223,8 +224,7 @@ public static function getColumns() TextColumn::make('materials.name') ->label(__('map_points.materials')) ->searchable() - ->limitList(2) - ->sortable(), + ->limitList(2), TextColumn::make('county.name') ->label(__('map_points.county')) @@ -246,6 +246,11 @@ public static function getColumns() ->sortable() ->wrap(), + TextColumn::make('proximity_count') + ->badge() + ->color(fn ($state) => $state > 0 ? 'warning' : 'success') + ->label(__('map_points.proximity_count')), + TextColumn::make('status') ->sortable() ->badge() diff --git a/app/Filament/Resources/PointResource/Actions/Page/AddPoint.php b/app/Filament/Resources/PointResource/Actions/Page/AddPoint.php index 8e6fd25..a76de97 100644 --- a/app/Filament/Resources/PointResource/Actions/Page/AddPoint.php +++ b/app/Filament/Resources/PointResource/Actions/Page/AddPoint.php @@ -5,7 +5,6 @@ namespace App\Filament\Resources\PointResource\Actions\Page; use App\Enums\Point\Source; -use App\Enums\Point\Status; use App\Filament\Forms\Components\LeafletAutocomplete; use App\Models\MaterialCategory; use App\Models\Point; diff --git a/app/Filament/Resources/PointResource/Pages/ViewMapPoint.php b/app/Filament/Resources/PointResource/Pages/ViewMapPoint.php index 942ff59..a4cc81b 100644 --- a/app/Filament/Resources/PointResource/Pages/ViewMapPoint.php +++ b/app/Filament/Resources/PointResource/Pages/ViewMapPoint.php @@ -7,7 +7,6 @@ use App\Enums\Point\Status; use App\Filament\Forms\Components\LeafletAutocomplete; use App\Filament\Resources\PointResource; -use App\Models\ActionLog as ActionLogModel; use App\Models\PointType; use Dotswan\MapPicker\Infolists\MapEntry; use Filament\Actions\Action; @@ -26,8 +25,6 @@ use Filament\Infolists\Infolist; use Filament\Notifications\Notification; use Filament\Resources\Pages\ViewRecord; -use Filament\Tables\Columns\TextColumn; -use Filament\Tables\Table; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Support\HtmlString; @@ -340,12 +337,11 @@ public function infolist(Infolist $infolist): Infolist protected function getFooterWidgets(): array { - return [ - PointResource\Widgets\PointFromProximity::class - ]; + return [ + PointResource\Widgets\PointFromProximity::class, + ]; } - private function showField(string $string): bool { if ($this->record->serviceType === null) { diff --git a/app/Filament/Resources/PointResource/Widgets/PointFromProximity.php b/app/Filament/Resources/PointResource/Widgets/PointFromProximity.php index 1add727..145f77e 100644 --- a/app/Filament/Resources/PointResource/Widgets/PointFromProximity.php +++ b/app/Filament/Resources/PointResource/Widgets/PointFromProximity.php @@ -9,15 +9,12 @@ use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; use Filament\Widgets\TableWidget as BaseWidget; -use Illuminate\Contracts\Support\Htmlable; -use Illuminate\Contracts\View\View; -use Illuminate\Database\Eloquent\Model; class PointFromProximity extends BaseWidget { public ?Point $record = null; - protected int | string | array $columnSpan='full'; + protected int | string | array $columnSpan = 'full'; public function table(Table $table): Table { diff --git a/app/Filament/Resources/RecycleMaterialsResource.php b/app/Filament/Resources/RecycleMaterialsResource.php index bc104a7..b1d8ee7 100644 --- a/app/Filament/Resources/RecycleMaterialsResource.php +++ b/app/Filament/Resources/RecycleMaterialsResource.php @@ -25,7 +25,6 @@ class RecycleMaterialsResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-arrow-path'; - public static function getModelLabel(): string { return __('materials.singular'); @@ -35,6 +34,7 @@ public static function getPluralLabel(): string { return __('materials.plural'); } + public static function getNavigationGroup(): ?string { return __('nav.settings'); diff --git a/app/Filament/Resources/UserGroupResource.php b/app/Filament/Resources/UserGroupResource.php index ed2e2ad..5f7464c 100644 --- a/app/Filament/Resources/UserGroupResource.php +++ b/app/Filament/Resources/UserGroupResource.php @@ -24,6 +24,7 @@ public static function getModelLabel(): string { return __('users.group.singular'); } + public static function getNavigationGroup(): ?string { return __('nav.settings'); diff --git a/app/Filament/Resources/UserResource.php b/app/Filament/Resources/UserResource.php index bcd60d6..f3df9c3 100644 --- a/app/Filament/Resources/UserResource.php +++ b/app/Filament/Resources/UserResource.php @@ -30,7 +30,7 @@ class UserResource extends Resource public static function getNavigationGroup(): ?string { - return __('nav.settings'); + return __('nav.settings'); } public static function form(Form $form): Form diff --git a/app/Http/Resources/ContributionResource.php b/app/Http/Resources/ContributionResource.php index e7cc403..b2c6633 100644 --- a/app/Http/Resources/ContributionResource.php +++ b/app/Http/Resources/ContributionResource.php @@ -23,7 +23,7 @@ public function toArray(Request $request): array (new Point)->getMorphClass() => $this->model, (new Problem)->getMorphClass() => $this->model->point, }; - if (!$point) { + if (! $point) { return []; } diff --git a/app/Models/Point.php b/app/Models/Point.php index 4882d4f..6625b8f 100644 --- a/app/Models/Point.php +++ b/app/Models/Point.php @@ -69,6 +69,10 @@ class Point extends Model implements HasMedia 'verified_at' => 'datetime', ]; + protected $appends = [ + 'proximity_count', + ]; + public function registerMediaCollections(): void { $this->addMediaCollection('default') @@ -329,4 +333,18 @@ public function status(): Attribute }); } + public function getProximityCountAttribute(): int + { + return self::query() + ->withCount('problems') + ->where('administered_by', $this->administered_by) + ->where('id', '!=', $this->id) + ->where('point_type_id', $this->point_type_id) + ->where('city_id', $this->city_id) + ->where('county_id', $this->county_id) + ->where('service_type_id', $this->service_type_id) + ->withDistanceSphere('location', $this->location) + ->whereDistance('location', $this->location, '<', 100) + ->count(); + } } diff --git a/lang/ro/map_points.php b/lang/ro/map_points.php index 03c10ab..2cd62b7 100644 --- a/lang/ro/map_points.php +++ b/lang/ro/map_points.php @@ -32,6 +32,7 @@ 'import_materials' => 'Importa materiale', 'use_default_values' => 'Foloseste valorile implicite', 'proximity_points' => 'Puncte in apropiere care au accealeasi caracteristici', + 'proximity_count' => 'Numar puncte posibil duplicate', 'distance' => 'Distanță', 'subheading' => ':serviceType :pointType administrat de :administeredBy alocat la grup :group', diff --git a/lang/ro/users.php b/lang/ro/users.php index 2e854f8..420f675 100644 --- a/lang/ro/users.php +++ b/lang/ro/users.php @@ -23,7 +23,7 @@ 'phone' => 'Telefon', 'password' => 'Parola', 'roles' => 'Roluri', - 'contributions_count'=> 'Numar contributii', + 'contributions_count' => 'Numar contributii', 'last_login_date' => 'Ultima datǎ de conectare', ];