mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
product options add cart
This commit is contained in:
parent
51b8e9607a
commit
6981ac09f0
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$factory->define(
|
|
||||||
Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel::class,
|
|
||||||
function (Faker\Generator $faker) {
|
|
||||||
return [
|
|
||||||
//'title' => $faker->words(2),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$factory->define(
|
|
||||||
Visiosoft\AdvsModule\OptionsConfiguration\OptionsConfigurationModel::class,
|
|
||||||
function (Faker\Generator $faker) {
|
|
||||||
return [
|
|
||||||
//'title' => $faker->words(2),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$factory->define(
|
|
||||||
Visiosoft\AdvsModule\Productoption\ProductoptionModel::class,
|
|
||||||
function (Faker\Generator $faker) {
|
|
||||||
return [
|
|
||||||
//'title' => $faker->words(2),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$factory->define(
|
|
||||||
Visiosoft\AdvsModule\ProductoptionsValue\ProductoptionsValueModel::class,
|
|
||||||
function (Faker\Generator $faker) {
|
|
||||||
return [
|
|
||||||
//'title' => $faker->words(2),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@ -15,7 +15,12 @@ class VisiosoftModuleAdvsCreateProductoptionsStream extends Migration
|
|||||||
protected $delete = true;
|
protected $delete = true;
|
||||||
|
|
||||||
protected $fields = [
|
protected $fields = [
|
||||||
'categories' => 'anomaly.field_type.select',
|
'categories' => [
|
||||||
|
'type' => 'anomaly.field_type.select',
|
||||||
|
'config' => [
|
||||||
|
'handler' => 'Visiosoft\AdvsModule\OptionHandler\CategoriesOptions@handle'
|
||||||
|
]
|
||||||
|
],
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* The stream definition.
|
* The stream definition.
|
||||||
|
|||||||
@ -52,6 +52,7 @@ class VisiosoftModuleAdvsCreateOptionConfigurationStream extends Migration
|
|||||||
],
|
],
|
||||||
'option_json' => [
|
'option_json' => [
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'unique' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -44,10 +44,41 @@
|
|||||||
{{ adv.created_at|date('d/m/Y') }}
|
{{ adv.created_at|date('d/m/Y') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Detail With Block -->
|
|
||||||
{{ addBlock('ad-detail/details',{'adv':adv, 'options':options})|raw }}
|
{# {{ dd(configurations) }}#}
|
||||||
{{ addBlock('ad-detail/widget-details',{'adv':adv})|raw }}
|
{% if configurations != null %}
|
||||||
<!-- Detail With Block -->
|
<div class="col-12 justify-content-start pl-0 row m-0">
|
||||||
|
<form action="{{ route('configuration::add_cart') }}" class="">
|
||||||
|
<div class="row mb-1">
|
||||||
|
<div class="input-group col-12">
|
||||||
|
<select name="configuration" id="" class="form-control">
|
||||||
|
{% for key, configuration in configurations %}
|
||||||
|
<option value="{{ key }}">
|
||||||
|
{{ configuration.name }} - {{ configuration.price }} {{ configuration.currency }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="input-group col-6 quantity-row">
|
||||||
|
<input type="number" data-id="29" name="quantity" class="form-control text-center quantity" value="1" min="1">
|
||||||
|
</div>
|
||||||
|
<div class="col-6 p-0">
|
||||||
|
<button class="btn btn-success text-white" type="submit">
|
||||||
|
<i class="fa fa-shopping-cart"></i>
|
||||||
|
Sepete Ekle
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<!-- Detail With Block -->
|
||||||
|
{{ addBlock('ad-detail/details',{'adv':adv, 'options':options})|raw }}
|
||||||
|
{{ addBlock('ad-detail/widget-details',{'adv':adv})|raw }}
|
||||||
|
<!-- Detail With Block -->
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if adv.isCorporate == 2 %}
|
{% if adv.isCorporate == 2 %}
|
||||||
<div class="col-md-12 m-2">
|
<div class="col-md-12 m-2">
|
||||||
|
|||||||
@ -14,6 +14,10 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% set continueLink = url_route('adv_detail_seo', [adv.slug, adv.id]) %}
|
{% set continueLink = url_route('adv_detail_seo', [adv.slug, adv.id]) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<a href="{{ route('visiosoft.module.advs::user.configrations.create') }}?ad={{ adv.id }}"
|
||||||
|
class="btn btn-warning shadow-sm mr-4 text-white">
|
||||||
|
Konfigürasyon Oluştur
|
||||||
|
</a>
|
||||||
<a href="{{ url_route('visiosoft.module.advs::edit_adv', [adv.id]) }}"
|
<a href="{{ url_route('visiosoft.module.advs::edit_adv', [adv.id]) }}"
|
||||||
class="btn preview-edit shadow-sm border">
|
class="btn preview-edit shadow-sm border">
|
||||||
{{ trans('visiosoft.module.advs::field.edit') }}
|
{{ trans('visiosoft.module.advs::field.edit') }}
|
||||||
@ -27,6 +31,10 @@
|
|||||||
<div class="preview-overlay position-absolute"></div>
|
<div class="preview-overlay position-absolute"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="preview-actions text-center">
|
<div class="preview-actions text-center">
|
||||||
|
<a href="{{ route('visiosoft.module.advs::user.configrations.create') }}?ad={{ adv.id }}"
|
||||||
|
class="btn btn-warning shadow-sm mr-4 text-white">
|
||||||
|
Konfigürasyon Oluştur
|
||||||
|
</a>
|
||||||
<a href="{{ url_route('visiosoft.module.advs::edit_adv', [adv.id]) }}" class="btn preview-edit shadow-sm border">
|
<a href="{{ url_route('visiosoft.module.advs::edit_adv', [adv.id]) }}" class="btn preview-edit shadow-sm border">
|
||||||
{{ trans('visiosoft.module.advs::field.edit') }}
|
{{ trans('visiosoft.module.advs::field.edit') }}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@ -447,4 +447,8 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
|||||||
->orderBy('count_show_ad', 'desc')
|
->orderBy('count_show_ad', 'desc')
|
||||||
->paginate(setting_value('visiosoft.module.advs::popular_ads_limit', setting_value('streams::per_page')));
|
->paginate(setting_value('visiosoft.module.advs::popular_ads_limit', setting_value('streams::per_page')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getName($id){
|
||||||
|
return $this->find($id)->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,4 +44,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
|||||||
public function getByUsersIDs($usersIDs);
|
public function getByUsersIDs($usersIDs);
|
||||||
|
|
||||||
public function getPopular();
|
public function getPopular();
|
||||||
|
|
||||||
|
public function getName($id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,7 +221,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
|||||||
// Others
|
// Others
|
||||||
'advs/ttr/{id}' => 'Visiosoft\PackagesModule\Http\Controller\packageFEController@advsStatusbyUser',
|
'advs/ttr/{id}' => 'Visiosoft\PackagesModule\Http\Controller\packageFEController@advsStatusbyUser',
|
||||||
|
|
||||||
//Configrations Admin Controller
|
//Configurations Admin Controller
|
||||||
'admin/advs/option_configuration/create' => [
|
'admin/advs/option_configuration/create' => [
|
||||||
'as' => 'visiosoft.module.advs::configrations.create',
|
'as' => 'visiosoft.module.advs::configrations.create',
|
||||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@create',
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@create',
|
||||||
@ -230,6 +230,18 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
|||||||
'as' => 'visiosoft.module.advs::configrations.index',
|
'as' => 'visiosoft.module.advs::configrations.index',
|
||||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@index',
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@index',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
//Configuration Controller
|
||||||
|
'advs/option_configuration/create' => [
|
||||||
|
'as' => 'visiosoft.module.advs::user.configrations.create',
|
||||||
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@create',
|
||||||
|
],
|
||||||
|
'conf/addCart' => [
|
||||||
|
'as' => 'configuration::add_cart',
|
||||||
|
'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@confAddCart',
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,59 @@
|
|||||||
|
<?php namespace Visiosoft\AdvsModule\Http\Controller;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||||
|
use Anomaly\Streams\Platform\Model\Configuration\ConfigurationConfigurationEntryModel;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||||
|
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||||
|
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
|
||||||
|
use Visiosoft\AdvsModule\OptionConfiguration\Form\OptionConfigurationFormBuilder;
|
||||||
|
use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel;
|
||||||
|
use Visiosoft\CartsModule\Cart\CartModel;
|
||||||
|
use Visiosoft\CartsModule\Cart\CartRepository;
|
||||||
|
use Visiosoft\CartsModule\Cart\Command\GetCart;
|
||||||
|
|
||||||
|
class OptionConfigurationController extends PublicController
|
||||||
|
{
|
||||||
|
private $advRepository;
|
||||||
|
private $adv_model;
|
||||||
|
private $optionConfigurationModel;
|
||||||
|
private $optionConfigurationRepository;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
AdvRepositoryInterface $advRepository,
|
||||||
|
AdvModel $advModel,
|
||||||
|
OptionConfigurationModel $optionConfigurationModel,
|
||||||
|
OptionConfigurationRepositoryInterface $optionConfigurationRepository
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->advRepository = $advRepository;
|
||||||
|
$this->adv_model = $advModel;
|
||||||
|
$this->optionConfigurationModel = $optionConfigurationModel;
|
||||||
|
$this->optionConfigurationRepository = $optionConfigurationRepository;
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(OptionConfigurationFormBuilder $form)
|
||||||
|
{
|
||||||
|
$form->setOption('redirect', route('advs_preview', [request('ad')]));
|
||||||
|
return $form->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function confAddCart()
|
||||||
|
{
|
||||||
|
$conf = $this->optionConfigurationRepository->find($this->request->configuration);
|
||||||
|
|
||||||
|
$conf->name = $this->optionConfigurationRepository->getName($this->request->configuration);
|
||||||
|
|
||||||
|
$this->adv_model->authControl();
|
||||||
|
|
||||||
|
if ($conf->stock < $this->request->quantity){
|
||||||
|
return redirect()->back()->with('warning', [trans('visiosoft.module.carts::message.error1in2')]);
|
||||||
|
}else{
|
||||||
|
$cart = $this->dispatch(new GetCart());
|
||||||
|
$cart->add($conf, $this->request->quantity);
|
||||||
|
return $this->redirect->to(route('visiosoft.module.carts::cart'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,6 +19,10 @@ use Visiosoft\AdvsModule\Adv\Event\showAdPhone;
|
|||||||
use Visiosoft\AdvsModule\Adv\Event\viewAd;
|
use Visiosoft\AdvsModule\Adv\Event\viewAd;
|
||||||
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
|
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
|
||||||
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
||||||
|
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
|
||||||
|
use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel;
|
||||||
|
use Visiosoft\AdvsModule\Productoption\Contract\ProductoptionRepositoryInterface;
|
||||||
|
use Visiosoft\AdvsModule\ProductoptionsValue\Contract\ProductoptionsValueRepositoryInterface;
|
||||||
use Visiosoft\AlgoliaModule\Search\SearchModel;
|
use Visiosoft\AlgoliaModule\Search\SearchModel;
|
||||||
use Visiosoft\CatsModule\Category\CategoryModel;
|
use Visiosoft\CatsModule\Category\CategoryModel;
|
||||||
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
||||||
@ -40,6 +44,10 @@ class AdvsController extends PublicController
|
|||||||
private $adv_model;
|
private $adv_model;
|
||||||
private $adv_repository;
|
private $adv_repository;
|
||||||
|
|
||||||
|
private $optionConfigurationRepository;
|
||||||
|
private $productOptionRepository;
|
||||||
|
private $productOptionsValueRepository;
|
||||||
|
|
||||||
private $country_repository;
|
private $country_repository;
|
||||||
|
|
||||||
private $city_model;
|
private $city_model;
|
||||||
@ -66,6 +74,10 @@ class AdvsController extends PublicController
|
|||||||
AdvModel $advModel,
|
AdvModel $advModel,
|
||||||
AdvRepositoryInterface $advRepository,
|
AdvRepositoryInterface $advRepository,
|
||||||
|
|
||||||
|
OptionConfigurationRepositoryInterface $optionConfigurationRepository,
|
||||||
|
ProductoptionRepositoryInterface $productOptionRepository,
|
||||||
|
ProductoptionsValueRepositoryInterface $productOptionsValueRepository,
|
||||||
|
|
||||||
CountryRepositoryInterface $country_repository,
|
CountryRepositoryInterface $country_repository,
|
||||||
|
|
||||||
CityModel $city_model,
|
CityModel $city_model,
|
||||||
@ -94,6 +106,10 @@ class AdvsController extends PublicController
|
|||||||
$this->adv_model = $advModel;
|
$this->adv_model = $advModel;
|
||||||
$this->adv_repository = $advRepository;
|
$this->adv_repository = $advRepository;
|
||||||
|
|
||||||
|
$this->optionConfigurationRepository = $optionConfigurationRepository;
|
||||||
|
$this->productOptionRepository = $productOptionRepository;
|
||||||
|
$this->productOptionsValueRepository = $productOptionsValueRepository;
|
||||||
|
|
||||||
$this->country_repository = $country_repository;
|
$this->country_repository = $country_repository;
|
||||||
|
|
||||||
$this->city_model = $city_model;
|
$this->city_model = $city_model;
|
||||||
@ -502,9 +518,11 @@ class AdvsController extends PublicController
|
|||||||
}
|
}
|
||||||
$this->template->set('meta_image', $coverPhoto);
|
$this->template->set('meta_image', $coverPhoto);
|
||||||
|
|
||||||
if ($adv->created_by_id == isset(auth()->user()->id) or $adv->status == "approved") {
|
$configurations = $this->optionConfigurationRepository->getConf($adv->id);
|
||||||
|
|
||||||
|
if ($adv->created_by_id == isset(auth()->user()->id) or $adv->status == "approved") {
|
||||||
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints',
|
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints',
|
||||||
'recommended_advs', 'categories', 'features', 'comments', 'qrSRC', 'options'));
|
'recommended_advs', 'categories', 'features', 'comments', 'qrSRC', 'options', 'configurations'));
|
||||||
} else {
|
} else {
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
@ -545,7 +563,7 @@ class AdvsController extends PublicController
|
|||||||
$isActiveDopings = $this->adv_model->is_enabled('dopings');
|
$isActiveDopings = $this->adv_model->is_enabled('dopings');
|
||||||
|
|
||||||
return $this->view->make('visiosoft.module.advs::new-ad/preview/preview',
|
return $this->view->make('visiosoft.module.advs::new-ad/preview/preview',
|
||||||
compact('adv', 'categories', 'features', 'isActiveDopings', 'options'));
|
compact('adv', 'categories', 'features', 'isActiveDopings', 'configurations'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocations()
|
public function getLocations()
|
||||||
|
|||||||
@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
|
|||||||
interface OptionConfigurationRepositoryInterface extends EntryRepositoryInterface
|
interface OptionConfigurationRepositoryInterface extends EntryRepositoryInterface
|
||||||
{
|
{
|
||||||
public function createConfigration($ad_id,$price,$currency,$stock,$option_json);
|
public function createConfigration($ad_id,$price,$currency,$stock,$option_json);
|
||||||
|
|
||||||
|
public function getConf($ad_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,15 @@
|
|||||||
<?php namespace Visiosoft\AdvsModule\OptionConfiguration;
|
<?php namespace Visiosoft\AdvsModule\OptionConfiguration;
|
||||||
|
|
||||||
|
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||||
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationInterface;
|
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationInterface;
|
||||||
use Anomaly\Streams\Platform\Model\Advs\AdvsOptionConfigurationEntryModel;
|
use Anomaly\Streams\Platform\Model\Advs\AdvsOptionConfigurationEntryModel;
|
||||||
|
|
||||||
class OptionConfigurationModel extends AdvsOptionConfigurationEntryModel implements OptionConfigurationInterface
|
class OptionConfigurationModel extends AdvsOptionConfigurationEntryModel implements OptionConfigurationInterface
|
||||||
{
|
{
|
||||||
|
public function getName($id)
|
||||||
|
{
|
||||||
|
$configuration = $this->find($id);
|
||||||
|
$adv = $this->adv_model->find($configuration->parent_adv_id);
|
||||||
|
dd($adv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,36 +1,108 @@
|
|||||||
<?php namespace Visiosoft\AdvsModule\OptionConfiguration;
|
<?php namespace Visiosoft\AdvsModule\OptionConfiguration;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Model\Configuration\ConfigurationConfigurationEntryModel;
|
||||||
|
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||||
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
|
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||||
|
use Visiosoft\AdvsModule\ProductoptionsValue\Contract\ProductoptionsValueRepositoryInterface;
|
||||||
|
|
||||||
class OptionConfigurationRepository extends EntryRepository implements OptionConfigurationRepositoryInterface
|
class OptionConfigurationRepository extends EntryRepository implements OptionConfigurationRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The entry model.
|
* The entry model.
|
||||||
*
|
*
|
||||||
* @var OptionConfigurationModel
|
* @var OptionConfigurationModel
|
||||||
*/
|
*/
|
||||||
protected $model;
|
protected $model;
|
||||||
|
protected $advRepository;
|
||||||
|
protected $productOptionsValueRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new OptionConfigurationRepository instance.
|
* Create a new OptionConfigurationRepository instance.
|
||||||
*
|
*
|
||||||
* @param OptionConfigurationModel $model
|
* @param OptionConfigurationModel $model
|
||||||
*/
|
*/
|
||||||
public function __construct(OptionConfigurationModel $model)
|
public function __construct(
|
||||||
{
|
OptionConfigurationModel $model,
|
||||||
$this->model = $model;
|
AdvRepositoryInterface $advRepository,
|
||||||
}
|
ProductoptionsValueRepositoryInterface $productoptionsValueRepository
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->model = $model;
|
||||||
|
$this->advRepository = $advRepository;
|
||||||
|
$this->productOptionsValueRepository = $productoptionsValueRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public function createConfigration($ad_id,$price,$currency,$stock,$option_json)
|
public function createConfigration($ad_id, $price, $currency, $stock, $option_json)
|
||||||
{
|
{
|
||||||
return $this->create([
|
return $this->create([
|
||||||
'parent_adv_id' => $ad_id,
|
'parent_adv_id' => $ad_id,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'stock' => $stock,
|
'stock' => $stock,
|
||||||
'option_json' => $option_json,
|
'option_json' => $option_json,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConf($ad_id, $conf_id = null)
|
||||||
|
{
|
||||||
|
$adv = $this->advRepository->find($ad_id);
|
||||||
|
$configurations = array();
|
||||||
|
|
||||||
|
if ($conf_id == null) {
|
||||||
|
$product_configurations = $this->model->where('stock', '>', '0')->where('parent_adv_id', $ad_id)->get();
|
||||||
|
|
||||||
|
foreach ($product_configurations as $product_configuration) {
|
||||||
|
$configurations_item = json_decode($product_configuration->option_json, true);
|
||||||
|
$option_group_value = "";
|
||||||
|
foreach ($configurations_item as $option_id => $value) {
|
||||||
|
$value_entry = $this->productOptionsValueRepository->find($value);
|
||||||
|
$option_group_value .= " " . $value_entry->getName();
|
||||||
|
}
|
||||||
|
$configurations[$product_configuration->getId()] = [
|
||||||
|
'name' => $option_group_value,
|
||||||
|
'price' => $product_configuration->price,
|
||||||
|
'currency' => $product_configuration->currency,
|
||||||
|
'stock' => $product_configuration->stock,
|
||||||
|
'adv' => $adv->name . ' (' . trim($option_group_value, ' ') . ')',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$product_configuration = $this->model->find($conf_id);
|
||||||
|
$configurations_item = json_decode($product_configuration->option_json, true);
|
||||||
|
$option_group_value = "";
|
||||||
|
|
||||||
|
foreach ($configurations_item as $option_id => $value) {
|
||||||
|
$value_entry = $this->productOptionsValueRepository->find($value);
|
||||||
|
$option_group_value .= " " . $value_entry->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
$configurations = [
|
||||||
|
'name' => trim($option_group_value),
|
||||||
|
'price' => $product_configuration->price,
|
||||||
|
'currency' => $product_configuration->currency,
|
||||||
|
'stock' => $product_configuration->stock,
|
||||||
|
'adv' => $adv->name . ' (' . trim($option_group_value, ' ') . ')',
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $configurations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName($id){
|
||||||
|
$configuration = $this->find($id);
|
||||||
|
$adv = $this->advRepository->getName($configuration->parent_adv_id);
|
||||||
|
|
||||||
|
$configurations_item = json_decode($configuration->option_json, true);
|
||||||
|
$option_group_value = "";
|
||||||
|
|
||||||
|
foreach ($configurations_item as $option_id => $value) {
|
||||||
|
$value_entry = $this->productOptionsValueRepository->find($value);
|
||||||
|
$option_group_value .= " " . $value_entry->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $adv . ' | ' . trim($option_group_value, ' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class OptionConfigurationTableColumns
|
|||||||
AdvRepositoryInterface $advRepository) {
|
AdvRepositoryInterface $advRepository) {
|
||||||
|
|
||||||
$adv = $advRepository->findById($entry->parent_adv_id);
|
$adv = $advRepository->findById($entry->parent_adv_id);
|
||||||
return "<span><a href='" . route('adv_detail', [$entry->parent_adv_id]) ."'>$adv->name</a></span>";
|
return "<span><a href='" . route('adv_detail', [$entry->parent_adv_id]) . "'>$adv->name</a></span>";
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'option_json' => [
|
'option_json' => [
|
||||||
@ -35,8 +35,8 @@ class OptionConfigurationTableColumns
|
|||||||
$productOptionsValue = $productOptionsValueRepository->findBy('entry_id', $value);
|
$productOptionsValue = $productOptionsValueRepository->findBy('entry_id', $value);
|
||||||
|
|
||||||
$text .=
|
$text .=
|
||||||
'<span class="tag tag-sm tag-info mr-1">'.
|
'<span class="tag tag-sm tag-info mr-1">' .
|
||||||
$productOption->name . ': ' . $productOptionsValue->name.
|
$productOption->name . ': ' . $productOptionsValue->name .
|
||||||
'</span>';
|
'</span>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,21 @@
|
|||||||
|
<?php namespace Visiosoft\AdvsModule\OptionHandler;
|
||||||
|
|
||||||
|
use Anomaly\SelectFieldType\SelectFieldType;
|
||||||
|
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
||||||
|
|
||||||
|
class CategoriesOptions
|
||||||
|
{
|
||||||
|
private $categoryRepository;
|
||||||
|
|
||||||
|
public function __construct(CategoryRepositoryInterface $categoryRepository)
|
||||||
|
{
|
||||||
|
$this->categoryRepository = $categoryRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(SelectFieldType $fieldType)
|
||||||
|
{
|
||||||
|
$categories = $this->categoryRepository->mainCats();
|
||||||
|
$options[] = $categories->pluck('name', 'id');
|
||||||
|
$fieldType->setOptions($options);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
|
|||||||
|
|
||||||
interface ProductoptionsValueInterface extends EntryInterface
|
interface ProductoptionsValueInterface extends EntryInterface
|
||||||
{
|
{
|
||||||
|
public function getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,8 @@ use Anomaly\Streams\Platform\Model\Advs\AdvsProductoptionsValueEntryModel;
|
|||||||
|
|
||||||
class ProductoptionsValueModel extends AdvsProductoptionsValueEntryModel implements ProductoptionsValueInterface
|
class ProductoptionsValueModel extends AdvsProductoptionsValueEntryModel implements ProductoptionsValueInterface
|
||||||
{
|
{
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationFormBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationCollectionTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationCriteriaTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationModelTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationObserverTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationPresenterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationRepositoryTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationRouterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationSeederTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionConfiguration;
|
|
||||||
|
|
||||||
class OptionConfigurationTableBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationFormBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationCollectionTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationCriteriaTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationModelTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationObserverTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationPresenterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationRepositoryTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationRouterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationSeederTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\OptionsConfiguration;
|
|
||||||
|
|
||||||
class OptionsConfigurationTableBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionFormBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionCollectionTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionCriteriaTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionModelTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionObserverTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionPresenterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionRepositoryTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionRouterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionSeederTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\Productoption;
|
|
||||||
|
|
||||||
class ProductoptionTableBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueFormBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueCollectionTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueCriteriaTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueModelTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueObserverTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValuePresenterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueRepositoryTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueRouterTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueSeederTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Visiosoft\AdvsModule\Test\Unit\ProductoptionsValue;
|
|
||||||
|
|
||||||
class ProductoptionsValueTableBuilderTest extends \TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user