Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Sep 4, 2024
1 parent 8089057 commit b23309f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=

NOMINATIM_URL=http://127.0.0.1:8081
FORWARD_NOMINATIM_PORT=8081

# SCOUT_DRIVER=typesense
# TYPESENSE_HOST=127.0.0.1
# TYPESENSE_PORT=8108
Expand Down
1 change: 0 additions & 1 deletion app/DataTransferObjects/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

public function __construct(array $location)
{
// dump($location);
$this->address = $this->collectAddress($location);

$this->county = $this->firstFromAddress(['county'], 'București');
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/MapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function suggest(Request $request, MapCoordinates $coordinates): JsonReso
->query(
fn (Builder $query) => $query
->with('serviceType:id,slug')
->with('pointType')
->orderByDistance('location', $coordinates->getCenter())
)
->get()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/SuggestionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function toArray(Request $request): array
protected function getPointArray(): array
{
return [
'name' => $this->name,
'name' => $this->business_name ?? $this->pointType->name,
'description' => $this->address,
'url' => route('front.map.point', $this),
'type' => 'point',
Expand Down
13 changes: 12 additions & 1 deletion database/factories/PointFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use App\Models\City;
use App\Models\Point;
use App\Models\PointGroup;
use App\Models\PointType;
use App\Models\ServiceType;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Collection;
Expand All @@ -34,7 +36,7 @@ public function definition(): array
fake()->longitude(min: 20.29, max: 29.61)
),
'address' => fake()->address(),
'business_name' => fake()->boolean() ? fake()->company() : null,
'business_name' => null,
'phone' => fake()->phoneNumber(),
'email' => fake()->email(),
'website' => fake()->url(),
Expand All @@ -51,6 +53,15 @@ public function definition(): array
];
}

public function withType(ServiceType $serviceType, PointType $pointType): static
{
return $this->state(fn (array $attributes) => [
'business_name' => $serviceType->can_have_business_name ? fake()->company() : null,
'service_type_id' => $serviceType->id,
'point_type_id' => $pointType->id,
]);
}

public function withMaterials(Collection $materials): static
{
return $this->afterCreating(function (Point $point) use ($materials) {
Expand Down
7 changes: 3 additions & 4 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ public function run(): void
...Point::factory(500)
->inCity($cities->random())
->withMaterials($materials->random(3))
->create([
'service_type_id' => $pointType->service_type_id,
'point_type_id' => $pointType->id,
])
->withType($serviceType, $pointType)
->create()
);
}

foreach ($serviceType->issueTypes as $issueType) {
$point = $points->random();

Expand Down

0 comments on commit b23309f

Please sign in to comment.