diff --git a/addons/default/visiosoft/profile-module/src/Adress/AdressModel.php b/addons/default/visiosoft/profile-module/src/Adress/AdressModel.php index 36724c496..9f623e685 100644 --- a/addons/default/visiosoft/profile-module/src/Adress/AdressModel.php +++ b/addons/default/visiosoft/profile-module/src/Adress/AdressModel.php @@ -1,30 +1,41 @@ where('id',$id)->whereNull('deleted_at'); + return AdressModel::query()->where('id', $id)->whereNull('deleted_at'); } - public function getAdressFirst($id) { + public function getAdressFirst($id) + { return $this->getAdress($id)->first(); } public function getUserAdress($id = null) { if ($id != null) { - return $this->query()->where('user_id',$id)->whereNull('deleted_at')->get(); + return $this->query()->where('user_id', $id)->whereNull('deleted_at')->get(); } return $this->query()->where('user_id', Auth::id())->whereNull('deleted_at')->get(); } + public function getCountry() + { + return app(CountryRepositoryInterface::class)->find($this->country_id); + } + public function getCity() + { + return app(CityRepositoryInterface::class)->find($this->city); + } } diff --git a/addons/default/visiosoft/profile-module/src/Adress/AdressRepository.php b/addons/default/visiosoft/profile-module/src/Adress/AdressRepository.php index ff52642bf..0bb69dc28 100644 --- a/addons/default/visiosoft/profile-module/src/Adress/AdressRepository.php +++ b/addons/default/visiosoft/profile-module/src/Adress/AdressRepository.php @@ -27,4 +27,18 @@ class AdressRepository extends EntryRepository implements AdressRepositoryInterf { return $this->newQuery()->where('user_id', $user_id)->get(); } + + public function createAddress($name, $user_id, $first_name, $last_name, $country_id, $city_id, $content, $gsm_phone) + { + return $this->create([ + 'adress_name' => $name, + 'user_id' => $user_id, + 'adress_first_name' => $first_name, + 'adress_last_name' => $last_name, + 'country_id' => $country_id, + 'city' => $city_id, + 'adress_content' => $content, + 'adress_gsm_phone' => $gsm_phone, + ]); + } } diff --git a/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressInterface.php b/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressInterface.php index eee3bd4dc..03db90b61 100644 --- a/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressInterface.php +++ b/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressInterface.php @@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; interface AdressInterface extends EntryInterface { - + public function getCountry(); } diff --git a/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressRepositoryInterface.php b/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressRepositoryInterface.php index 3c4cecd65..24002ac9c 100644 --- a/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressRepositoryInterface.php +++ b/addons/default/visiosoft/profile-module/src/Adress/Contract/AdressRepositoryInterface.php @@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface AdressRepositoryInterface extends EntryRepositoryInterface { public function findByUser($user_id); + + public function createAddress($name, $user_id, $first_name, $last_name, $country_id, $city_id, $content, $gsm_phone); }