Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Nov 7, 2024
1 parent 0ed282f commit 29863d9
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ protected function setUp(): void
'location' => new PointObject($data['location']['lat'], $data['location']['lng']),
'county_id' => $data['county_id'],
'city_id' => $data['city_id'],
'status' => Status::VERIFIED,
'address' => $data['address'],
'business_name' => $data['business_name'] ?? null,
'administered_by' => $data['administered_by'] ?? null,
Expand All @@ -155,6 +154,7 @@ protected function setUp(): void
'offers_vouchers' => $data['offers_vouchers'] ?? null,
'free_of_charge' => $data['free_of_charge'] ?? null,
'website' => $data['website'] ?? null,
'verified_at' => now(),
'email' => $data['email'] ?? null,
'phone' => $data['phone'] ?? null,
]);
Expand Down
37 changes: 9 additions & 28 deletions app/Filament/Resources/PointResource/Pages/ViewMapPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ public function infolist(Infolist $infolist): Infolist
Section::make(__('map_points.sections.location'))
->schema(
[

TextEntry::make('address')
->icon('heroicon-s-map-pin')
->formatStateUsing(function (string $state, $record) {
return \sprintf('%s, %s, %s', $record->address, $record->city->name, $record->county->name);
})
->label(__('map_points.fields.address')),

TextEntry::make('location')
Expand Down Expand Up @@ -334,37 +338,14 @@ public function infolist(Infolist $infolist): Infolist
)->columns(12);
}

public function table(Table $table): Table
protected function getFooterWidgets(): array
{
return $table
->query(ActionLogModel::whereModel(\get_class($this->getRecord()))->whereModelId($this->getRecord()->id)->orderBy('created_at', 'desc'))
->columns([
TextColumn::make('user.name')
->formatStateUsing(function (string $state, $record) {
})
->html(),
TextColumn::make('action')
->formatStateUsing(function (string $state, $record) {
return trans('actions.' . $record->action);
})
->html(),
TextColumn::make('old_values')
->formatStateUsing(function (string $state, $record) {
return ActionLogModel::formatValuesText($record, 'old_values');
})
->wrap()
->html(),
TextColumn::make('new_values')
->formatStateUsing(function (string $state, $record) {
return ActionLogModel::formatValuesText($record, 'new_values');
})
->wrap()
->html(),
TextColumn::make('created_at'),

]);
return [
PointResource\Widgets\PointFromProximity::class
];
}


private function showField(string $string): bool
{
if ($this->record->serviceType === null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\PointResource\Widgets;

use App\Filament\Resources\PointResource;
use App\Models\Point;
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';

public function table(Table $table): Table
{
return $table
->query(
Point::query()
->withCount('problems')
->where('administered_by', $this->record->administered_by)
->where('id', '!=', $this->record->id)
->where('point_type_id', $this->record->point_type_id)
->where('city_id', $this->record->city_id)
->where('county_id', $this->record->county_id)
->where('service_type_id', $this->record->service_type_id)
->withDistanceSphere('location', $this->record->location)
->whereDistance('location', $this->record->location, '<', 100)
)
->heading(__('map_points.proximity_points'))
->columns([TextColumn::make('distance')->label(__('map_points.distance')), ...PointResource::getColumns()]);
}
}
1 change: 1 addition & 0 deletions app/Models/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,5 @@ public function status(): Attribute
return Status::VERIFIED;
});
}

}
2 changes: 2 additions & 0 deletions lang/ro/map_points.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
'point_save_success' => 'Punct salvat cu succes',
'import_materials' => 'Importa materiale',
'use_default_values' => 'Foloseste valorile implicite',
'proximity_points' => 'Puncte in apropiere care au accealeasi caracteristici',
'distance' => 'Distanță',

'subheading' => ':serviceType :pointType administrat de :administeredBy alocat la grup :group',

Expand Down

0 comments on commit 29863d9

Please sign in to comment.