diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/field.php b/addons/default/visiosoft/advs-module/resources/lang/en/field.php
index eff1272dd..cd7e80b4e 100644
--- a/addons/default/visiosoft/advs-module/resources/lang/en/field.php
+++ b/addons/default/visiosoft/advs-module/resources/lang/en/field.php
@@ -380,4 +380,6 @@ return [
'tax' => [
'name' => 'Tax'
],
+ 'name_a_z' => 'Name (A to Z)',
+ 'name_z_a' => 'Name (Z to A)',
];
diff --git a/addons/default/visiosoft/advs-module/resources/lang/tr/field.php b/addons/default/visiosoft/advs-module/resources/lang/tr/field.php
index 01550dbbf..4bf7fb3b2 100644
--- a/addons/default/visiosoft/advs-module/resources/lang/tr/field.php
+++ b/addons/default/visiosoft/advs-module/resources/lang/tr/field.php
@@ -379,10 +379,9 @@ return [
'publish_at' => [
'name' => 'Yayın tarihi'
],
- 'tax' => [
- 'name' => 'Vergi'
- ],
'tax' => [
'name' => 'KDV Oranı'
],
+ 'name_a_z' => 'İlan Başlığı (A\'dan Z\'ye)',
+ 'name_z_a' => 'İlan Başlığı (Z\'den A\'ya)',
];
diff --git a/addons/default/visiosoft/advs-module/resources/views/list/partials/list-sort-by.twig b/addons/default/visiosoft/advs-module/resources/views/list/partials/list-sort-by.twig
index 2adb018aa..da28fe7a8 100644
--- a/addons/default/visiosoft/advs-module/resources/views/list/partials/list-sort-by.twig
+++ b/addons/default/visiosoft/advs-module/resources/views/list/partials/list-sort-by.twig
@@ -23,5 +23,11 @@
{{ trans("visiosoft.module.advs::field.address_z_a") }}
+
+ {{ trans("visiosoft.module.advs::field.name_a_z") }}
+
+
+ {{ trans("visiosoft.module.advs::field.name_z_a") }}
+
diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php
index a13e2f44f..8acd42a55 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php
@@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Visiosoft\AdvsModule\Adv\Contract\AdvInterface;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
+use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel;
use Visiosoft\AdvsModule\Support\Command\Currency;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\Country\CountryModel;
@@ -27,6 +28,10 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
'thumbnail',
];
+ protected $cascades = [
+ 'configurations',
+ ];
+
public function getDetailUrlAttribute()
{
// Checking for slug
@@ -36,6 +41,19 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
}
}
+ public function configurations()
+ {
+ return $this->hasMany(
+ OptionConfigurationModel::class,
+ 'parent_adv_id'
+ );
+ }
+
+ public function getConfigurations()
+ {
+ return $this->getAttribute('configurations');
+ }
+
public function getCurrencyPriceAttribute()
{
return app(Currency::class)->format($this->price, $this->currency);
diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
index a551531e4..1a8ce5a4a 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
@@ -189,6 +189,12 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$query = $query->join('location_cities_translations', 'advs_advs.city', '=', 'location_cities_translations.entry_id')
->orderBy('location_cities_translations.name', 'DESC');
break;
+ case "name_z_a":
+ $query = $query->orderBy('advs_advs_translations.name', 'DESC');
+ break;
+ case "name_a_z":
+ $query = $query->orderBy('advs_advs_translations.name', 'ASC');
+ break;
}
} else {
$query = $query->orderBy('advs_advs.created_at', 'desc');
diff --git a/addons/default/visiosoft/advs-module/src/OptionConfiguration/Contract/OptionConfigurationInterface.php b/addons/default/visiosoft/advs-module/src/OptionConfiguration/Contract/OptionConfigurationInterface.php
index 99be0f686..a8b6cadbc 100644
--- a/addons/default/visiosoft/advs-module/src/OptionConfiguration/Contract/OptionConfigurationInterface.php
+++ b/addons/default/visiosoft/advs-module/src/OptionConfiguration/Contract/OptionConfigurationInterface.php
@@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
interface OptionConfigurationInterface extends EntryInterface
{
- public function getName();
+ public function getName($add_name = true);
}
diff --git a/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php b/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php
index 9e54d6752..7b11c9080 100644
--- a/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php
+++ b/addons/default/visiosoft/advs-module/src/OptionConfiguration/OptionConfigurationModel.php
@@ -7,35 +7,46 @@ use Visiosoft\AdvsModule\ProductoptionsValue\Contract\ProductoptionsValueReposit
class OptionConfigurationModel extends AdvsOptionConfigurationEntryModel implements OptionConfigurationInterface
{
- public function getName()
- {
- if($adv = app(AdvRepositoryInterface::class)->find($this->parent_adv_id))
- {
- $configurations_item = json_decode($this->option_json, true);
- $option_group_value = "";
+ protected $appends = [
+ 'option_name'
+ ];
- foreach ($configurations_item as $option_id => $value) {
- $value_entry = app(ProductoptionsValueRepositoryInterface::class)->find($value);
- $option_group_value .= " " . $value_entry->getName();
- }
+ public function getOptionNameAttribute()
+ {
+ return $this->getName(false);
+ }
- return $adv->name . ' | ' . trim($option_group_value, ' ');
- }
- }
+ public function getName($add_name = true)
+ {
+ if ($adv = app(AdvRepositoryInterface::class)->find($this->parent_adv_id)) {
+ $configurations_item = json_decode($this->option_json, true);
+ $option_group_value = "";
- public function stockControl($id, $quantity)
- {
- $conf = $this->newQuery()->find($id);
- $stock = $conf->stock;
+ foreach ($configurations_item as $option_id => $value) {
+ $value_entry = app(ProductoptionsValueRepositoryInterface::class)->find($value);
+ $option_group_value .= " " . $value_entry->getName();
+ }
- if ($stock === NULL || $stock === 0) {
- return 0;
- }
+ $name = trim($option_group_value, ' ');
- if ($stock < $quantity) {
- return 0;
- }
+ return ($add_name) ? $adv->name . ' | ' . $name : $name;
+ }
+ return null;
+ }
- return 1;
- }
+ public function stockControl($id, $quantity)
+ {
+ $conf = $this->newQuery()->find($id);
+ $stock = $conf->stock;
+
+ if ($stock === NULL || $stock === 0) {
+ return 0;
+ }
+
+ if ($stock < $quantity) {
+ return 0;
+ }
+
+ return 1;
+ }
}