mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #1107 from openclassify/vedatakdogan
add configuration detail
This commit is contained in:
commit
cbe7a39774
@ -380,4 +380,6 @@ return [
|
||||
'tax' => [
|
||||
'name' => 'Tax'
|
||||
],
|
||||
'name_a_z' => 'Name (A to Z)',
|
||||
'name_z_a' => 'Name (Z to A)',
|
||||
];
|
||||
|
||||
@ -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)',
|
||||
];
|
||||
|
||||
@ -23,5 +23,11 @@
|
||||
<span class="dropdown-item sort-by-item" data-value="address_z_a">
|
||||
{{ trans("visiosoft.module.advs::field.address_z_a") }}
|
||||
</span>
|
||||
<span class="dropdown-item sort-by-item" data-value="name_a_z">
|
||||
{{ trans("visiosoft.module.advs::field.name_a_z") }}
|
||||
</span>
|
||||
<span class="dropdown-item sort-by-item" data-value="name_z_a">
|
||||
{{ trans("visiosoft.module.advs::field.name_z_a") }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
|
||||
|
||||
interface OptionConfigurationInterface extends EntryInterface
|
||||
{
|
||||
public function getName();
|
||||
public function getName($add_name = true);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user