Merge pull request #844 from openclassify/vedatakdogan

Added Address Functions & move require & added currency symbol
This commit is contained in:
Ozcan Durak 2020-12-01 11:53:45 +03:00 committed by GitHub
commit a7abd95ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 11 deletions

View File

@ -13,6 +13,7 @@
"wirelab/language_switcher-plugin": "^1.3", "wirelab/language_switcher-plugin": "^1.3",
"visiosoft/addblock-extension": "^1.1", "visiosoft/addblock-extension": "^1.1",
"ext-zip": "*", "ext-zip": "*",
"chumper/zipper": "^1.0" "chumper/zipper": "^1.0",
"sentry/sentry-laravel": "*"
} }
} }

View File

@ -1,30 +1,41 @@
<?php namespace Visiosoft\ProfileModule\Adress; <?php namespace Visiosoft\ProfileModule\Adress;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
use Visiosoft\ProfileModule\Adress\Contract\AdressInterface; use Visiosoft\ProfileModule\Adress\Contract\AdressInterface;
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel; use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
class AdressModel extends ProfileAdressEntryModel implements AdressInterface class AdressModel extends ProfileAdressEntryModel implements AdressInterface
{ {
public function getAdress($id = null) { public function getAdress($id = null)
if($id == null) {
{ if ($id == null) {
return AdressModel::query(); return AdressModel::query();
} }
return AdressModel::query()->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(); return $this->getAdress($id)->first();
} }
public function getUserAdress($id = null) public function getUserAdress($id = null)
{ {
if ($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(); 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);
}
} }

View File

@ -27,4 +27,18 @@ class AdressRepository extends EntryRepository implements AdressRepositoryInterf
{ {
return $this->newQuery()->where('user_id', $user_id)->get(); 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,
]);
}
} }

View File

@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
interface AdressInterface extends EntryInterface interface AdressInterface extends EntryInterface
{ {
public function getCountry();
} }

View File

@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
interface AdressRepositoryInterface extends EntryRepositoryInterface interface AdressRepositoryInterface extends EntryRepositoryInterface
{ {
public function findByUser($user_id); public function findByUser($user_id);
public function createAddress($name, $user_id, $first_name, $last_name, $country_id, $city_id, $content, $gsm_phone);
} }

View File

@ -79,8 +79,7 @@
"visiosoft/integer-field_type": "~2.1.0", "visiosoft/integer-field_type": "~2.1.0",
"visiosoft/list-field_type": "*", "visiosoft/list-field_type": "*",
"guzzlehttp/guzzle": "~6.3.3", "guzzlehttp/guzzle": "~6.3.3",
"composer/composer": "^1.6", "composer/composer": "^1.6"
"sentry/sentry-laravel": "*"
}, },
"replace": { "replace": {
"anomaly/streams-platform": "*" "anomaly/streams-platform": "*"

View File

@ -42,7 +42,7 @@ return [
'USD' => [ 'USD' => [
'name' => 'US Dollar', 'name' => 'US Dollar',
'direction' => 'ltr', 'direction' => 'ltr',
'symbol' => '', 'symbol' => '$',
'separator' => '.', 'separator' => '.',
'point' => ',', 'point' => ',',
'decimals' => 2, 'decimals' => 2,