Add location to account.

This commit is contained in:
James Cole
2019-12-28 19:49:33 +01:00
parent 950b706e7c
commit 021d421c6f
7 changed files with 155 additions and 42 deletions

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Factory;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Location;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Services\Internal\Support\AccountServiceTrait;
use FireflyIII\User;
@@ -131,6 +132,17 @@ class AccountFactory
}
}
$this->updateNote($return, $data['notes'] ?? '');
// store location
if (true === ($data['has_location'] ?? true) && null !== $return) {
$location = new Location;
$location->latitude = $data['latitude'] ?? 52.3167;
$location->longitude = $data['longitude'] ?? 5.55;
$location->zoom_level = $data['zoom_level'] ?? 6;
$location->locatable()->associate($return);
$location->save();
}
}
return $return;