refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Services\Account\Place;
use App\Models\Account\Place;
use App\Services\BaseService;
use App\Jobs\GetGPSCoordinate;
class CreatePlace extends BaseService
{
/**
* Get the validation rules that apply to the service.
*
* @return array
*/
public function rules()
{
return [
'account_id' => 'required|integer|exists:accounts,id',
'street' => 'nullable|string|max:255',
'city' => 'nullable|string|max:255',
'province' => 'nullable|string|max:255',
'postal_code' => 'nullable|string|max:255',
'country' => 'nullable|string|max:3',
'latitude' => 'nullable|numeric',
'longitude' => 'nullable|numeric',
];
}
/**
* Create a place.
*
* @param array $data
* @return Place
*/
public function execute(array $data): Place
{
$this->validate($data);
$place = Place::create([
'account_id' => $data['account_id'],
'street' => $this->nullOrValue($data, 'street'),
'city' => $this->nullOrValue($data, 'city'),
'province' => $this->nullOrValue($data, 'province'),
'postal_code' => $this->nullOrValue($data, 'postal_code'),
'country' => $this->nullOrValue($data, 'country'),
'latitude' => $this->nullOrValue($data, 'latitude'),
'longitude' => $this->nullOrValue($data, 'longitude'),
]);
if (is_null($place->latitude) || is_null($place->longitude)) {
$this->getGeocodingInfo($place);
}
return $place;
}
/**
* Get geocoding information about the place (lat/longitude).
*
* @param Place $place
* @return void
*/
private function getGeocodingInfo(Place $place)
{
if (config('monica.enable_geolocation') && ! is_null(config('monica.location_iq_api_key'))) {
GetGPSCoordinate::dispatch($place);
}
}
}