mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#1597 İlanlara ürün satış opisyonları
This commit is contained in:
parent
bbd993157a
commit
990f210f34
@ -250,5 +250,13 @@ class VisiosoftModuleAdvsCreateAdvsFields extends Migration
|
||||
'default_value' => 0,
|
||||
]
|
||||
],
|
||||
|
||||
// Options Fields
|
||||
"adv" => [
|
||||
"type" => "anomaly.field_type.relationship",
|
||||
"config" => [
|
||||
"related" => AdvModel::class,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Anomaly\Streams\Platform\Database\Migration\Migration;
|
||||
|
||||
class VisiosoftModuleAdvsCreateOptionsStream extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* This migration creates the stream.
|
||||
* It should be deleted on rollback.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $delete = true;
|
||||
|
||||
/**
|
||||
* The stream definition.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stream = [
|
||||
'slug' => 'options',
|
||||
'title_column' => 'name',
|
||||
'translatable' => false,
|
||||
'versionable' => false,
|
||||
'trashable' => false,
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* The stream assignments.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $assignments = [
|
||||
'name' => [
|
||||
'required' => true,
|
||||
],
|
||||
'adv' => [
|
||||
'required' => true,
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@ -16,4 +16,9 @@ return [
|
||||
'write',
|
||||
'delete',
|
||||
],
|
||||
'options' => [
|
||||
'read',
|
||||
'write',
|
||||
'delete',
|
||||
],
|
||||
];
|
||||
|
||||
@ -215,5 +215,10 @@ $(document).ready(function () {
|
||||
price = parseInt(price.replace(/\./g, ''));
|
||||
let decimal = parseInt($(".priceDecimalField").val());
|
||||
$('.priceHidden').find('input').val(parseFloat(price + "." + decimal));
|
||||
})
|
||||
});
|
||||
|
||||
// Add dynamic option creation
|
||||
$(".options-tags").select2({
|
||||
tags: true
|
||||
});
|
||||
});
|
||||
|
||||
@ -31,4 +31,5 @@ return [
|
||||
'update_category' => [
|
||||
'name' => 'Update Category'
|
||||
],
|
||||
'new_option' => 'New Option',
|
||||
];
|
||||
|
||||
@ -49,4 +49,12 @@ return [
|
||||
'delete' => 'Can delete cf values?',
|
||||
],
|
||||
],
|
||||
'options' => [
|
||||
'name' => 'Options',
|
||||
'option' => [
|
||||
'read' => 'Can read options?',
|
||||
'write' => 'Can create/edit options?',
|
||||
'delete' => 'Can delete options?',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@ -40,4 +40,7 @@ return [
|
||||
'general' => 'General',
|
||||
'ads' => 'Ads',
|
||||
'user' => 'User',
|
||||
'options' => [
|
||||
'title' => 'Options',
|
||||
],
|
||||
];
|
||||
|
||||
@ -19,4 +19,7 @@ return [
|
||||
'cf_values' => [
|
||||
'name' => 'Cf values',
|
||||
],
|
||||
'options' => [
|
||||
'name' => 'Options',
|
||||
],
|
||||
];
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Detail With Block -->
|
||||
{{ addBlock('ad-detail/details',{'adv':adv})|raw }}
|
||||
{{ addBlock('ad-detail/details',{'adv':adv, 'options':options})|raw }}
|
||||
{{ addBlock('ad-detail/widget-details',{'adv':adv})|raw }}
|
||||
<!-- Detail With Block -->
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
<div class="col-md-12">
|
||||
{% set form = form('advs', 'advs').entry(id).actions(['update']).get() %}
|
||||
{{ form_open({
|
||||
'id': 'createEditAdvForm',
|
||||
'class': 'form ' ~ form.options.class ,
|
||||
'enctype': 'multipart/form-data',
|
||||
'url': 'advs/save_adv',
|
||||
@ -94,6 +95,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row form-group select-options">
|
||||
<label for="selectOptions" class="col-sm-2">
|
||||
Options
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<select id="selectOptions" class="form-control options-tags" multiple="multiple"
|
||||
name="options[]">
|
||||
{% if count(options) %}
|
||||
{% for option in options %}
|
||||
<option selected="selected">{{ option.name }}</option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row form-group brand-name">
|
||||
<div class="col-md-12">
|
||||
<div class="field-group advs_desc">
|
||||
|
||||
@ -213,10 +213,10 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
return $this->getAdv()->where('advs_advs.id', $id)->first();
|
||||
}
|
||||
|
||||
public function addCart($item, $quantity = 1)
|
||||
public function addCart($item, $quantity = 1, $name = null)
|
||||
{
|
||||
$cart = $this->dispatch(new GetCart());
|
||||
$cart->add($item, $quantity);
|
||||
$cart->add($item, $quantity, $name);
|
||||
return $this->dispatch(new GetCart());
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,8 @@ use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
|
||||
use Visiosoft\AdvsModule\Listener\AddAdvsSettingsScript;
|
||||
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Option\OptionRepository;
|
||||
use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface;
|
||||
use Visiosoft\LocationModule\Village\VillageRepository;
|
||||
use Visiosoft\LocationModule\Village\VillageModel;
|
||||
@ -299,7 +301,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
||||
VillageRepositoryInterface::class => VillageRepository::class,
|
||||
CategoryRepositoryInterface::class => CategoryRepository::class,
|
||||
CountryRepositoryInterface::class => CountryRepository::class,
|
||||
AdvRepositoryInterface::class => AdvRepository::class,
|
||||
OptionRepositoryInterface::class => OptionRepository::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -14,6 +14,7 @@ use Visiosoft\AdvsModule\Adv\Event\showAdPhone;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
||||
use Visiosoft\LocationModule\City\CityRepository;
|
||||
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
||||
use function PMA\Util\get;
|
||||
@ -69,6 +70,8 @@ class AdvsController extends PublicController
|
||||
private $settings_repository;
|
||||
private $event;
|
||||
|
||||
private $optionRepository;
|
||||
|
||||
public function __construct(
|
||||
UserRepositoryInterface $userRepository,
|
||||
|
||||
@ -89,6 +92,8 @@ class AdvsController extends PublicController
|
||||
CategoryModel $categoryModel,
|
||||
CategoryRepositoryInterface $category_repository,
|
||||
|
||||
OptionRepositoryInterface $optionRepository,
|
||||
|
||||
SettingRepositoryInterface $settings_repository,
|
||||
|
||||
Dispatcher $events,
|
||||
@ -122,6 +127,7 @@ class AdvsController extends PublicController
|
||||
$this->requestHttp = $request;
|
||||
|
||||
parent::__construct();
|
||||
$this->optionRepository = $optionRepository;
|
||||
}
|
||||
|
||||
|
||||
@ -384,6 +390,8 @@ class AdvsController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
$options = $this->optionRepository->findAllBy('adv_id', $id);
|
||||
|
||||
if ($isCommentActive) {
|
||||
$CommentModel = new CommentModel();
|
||||
$comments = $CommentModel->getComments($adv->id)->get();
|
||||
@ -405,7 +413,8 @@ class AdvsController extends PublicController
|
||||
$this->template->set('meta_image', $coverPhoto);
|
||||
|
||||
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', 'recommended_advs', 'categories', 'features', 'comments', 'qrSRC'));
|
||||
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints',
|
||||
'recommended_advs', 'categories', 'features', 'comments', 'qrSRC', 'options'));
|
||||
} else {
|
||||
return back();
|
||||
}
|
||||
@ -434,6 +443,8 @@ class AdvsController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
$options = $this->optionRepository->findAllBy('adv_id', $id);
|
||||
|
||||
if ($this->adv_model->is_enabled('customfields')) {
|
||||
$features = app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->view($adv);
|
||||
}
|
||||
@ -441,7 +452,7 @@ class AdvsController extends PublicController
|
||||
$isActiveDopings = $this->adv_model->is_enabled('dopings');
|
||||
|
||||
return $this->view->make('visiosoft.module.advs::new-ad/preview/preview',
|
||||
compact('adv', 'categories', 'features', 'isActiveDopings'));
|
||||
compact('adv', 'categories', 'features', 'isActiveDopings', 'options'));
|
||||
}
|
||||
|
||||
public function getLocations()
|
||||
@ -563,6 +574,27 @@ class AdvsController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
// Create options
|
||||
$optionsIds = array();
|
||||
foreach ($request->options as $optionValue) {
|
||||
$option = $this->optionRepository->newQuery()
|
||||
->where('name', $optionValue)
|
||||
->where('adv_id', $request->update_id)
|
||||
->first();
|
||||
if (!$option) {
|
||||
$option = $this->optionRepository->create([
|
||||
'name' => $optionValue,
|
||||
'adv_id' => $request->update_id,
|
||||
]);
|
||||
}
|
||||
$optionsIds[] = $option->id;
|
||||
}
|
||||
$this->optionRepository->newQuery()
|
||||
->whereNotIn('id', $optionsIds)
|
||||
->where('adv_id', $request->update_id)
|
||||
->delete();
|
||||
|
||||
|
||||
$adv->is_get_adv = $request->is_get_adv;
|
||||
$adv->save();
|
||||
|
||||
@ -685,6 +717,8 @@ class AdvsController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
$options = $this->optionRepository->findAllBy('adv_id', $id);
|
||||
|
||||
//Cloudinary Module
|
||||
$isActiveCloudinary = new AdvModel();
|
||||
$isActiveCloudinary = $isActiveCloudinary->is_enabled('cloudinary');
|
||||
@ -705,7 +739,8 @@ class AdvsController extends PublicController
|
||||
$custom_fields = app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->edit($adv, $categories, $cats);
|
||||
}
|
||||
|
||||
return $this->view->make('visiosoft.module.advs::new-ad/new-create', compact('id', 'cats_d', 'request', 'Cloudinary', 'cities', 'adv', 'custom_fields'));
|
||||
return $this->view->make('visiosoft.module.advs::new-ad/new-create', compact('id', 'cats_d',
|
||||
'request', 'Cloudinary', 'cities', 'adv', 'custom_fields', 'options'));
|
||||
}
|
||||
|
||||
public function statusAds($id, $type, SettingRepositoryInterface $settings, Dispatcher $events)
|
||||
@ -963,11 +998,12 @@ class AdvsController extends PublicController
|
||||
{
|
||||
$id = $request->id;
|
||||
$quantity = $request->quantity;
|
||||
$name = $request->name;
|
||||
$thisModel = new AdvModel();
|
||||
$adv = $thisModel->isAdv($id);
|
||||
$response = array();
|
||||
if ($adv) {
|
||||
$cart = $thisModel->addCart($adv, $quantity);
|
||||
$cart = $thisModel->addCart($adv, $quantity, $name);
|
||||
$response['status'] = "success";
|
||||
} else {
|
||||
$response['status'] = "error";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user