mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
add configuration detail
This commit is contained in:
parent
19a0238b21
commit
1a3069085b
@ -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);
|
||||
|
||||
@ -7,35 +7,44 @@ 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();
|
||||
}
|
||||
|
||||
return $adv->name . ' | ' . trim($option_group_value, ' ');
|
||||
}
|
||||
}
|
||||
public function getName()
|
||||
{
|
||||
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;
|
||||
}
|
||||
return $adv->name . ' | ' . trim($option_group_value, ' ');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($stock < $quantity) {
|
||||
return 0;
|
||||
}
|
||||
public function stockControl($id, $quantity)
|
||||
{
|
||||
$conf = $this->newQuery()->find($id);
|
||||
$stock = $conf->stock;
|
||||
|
||||
return 1;
|
||||
}
|
||||
if ($stock === NULL || $stock === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($stock < $quantity) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user