Merge pull request #232 from openclassify/vedat

remove another query
This commit is contained in:
Fatih Alp 2020-01-15 18:26:20 +03:00 committed by GitHub
commit bc43f25698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 47 deletions

View File

@ -24,4 +24,6 @@ return [
],
'update_category_info' => 'Please update category.',
'filter_by_search_msg' => 'Filter By Search.',
'delete_author_error' => 'You cannot delete a post that does not belong to you',
'success_delete' => 'Ad Deleted',
];

View File

@ -24,4 +24,6 @@ return [
],
'update_category_info' => 'Lütfen kategoriyi güncelleyiniz.',
'filter_by_search_msg' => 'Aramanızı Daraltın.',
'delete_author_error' => 'Size ait olmayan bir ilanı silemezsiniz',
'success_delete' => 'İlan Silindi',
];

View File

@ -137,38 +137,10 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
}
}
foreach ($customParameters as $key => $customParameter) {
if ($key == 0) {
$jsonQuery = "(";
}
$cfId = $customParameter['id'];
$cfValue = $customParameter['value'];
$cf = "'" . $cfId . "'";
$valueCount = count($cfValue);
if ($this->model->is_enabled('customfields')) {
$query = app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->filterSearch($customParameters, $query);
}
if ($cfValue) {
foreach ($cfValue as $key1 => $value) {
if ($key1 == 0 and $cfValue > 1) {
$jsonQuery = $jsonQuery . "(";
}
$jsonQuery = $jsonQuery . 'JSON_CONTAINS(cf_json, \'"' . $value . '"\', ' . $cf . ')';
if ($key1 == $valueCount - 1 and $cfValue > 1) {
$jsonQuery = $jsonQuery . ")";
}
if ($key1 < $valueCount - 1) {
$jsonQuery = $jsonQuery . " or ";
} elseif ($key1 == $valueCount - 1 and $key != count($customParameters) - 1) {
$jsonQuery = $jsonQuery . " and ";
}
}
}
if ($key == count($customParameters) - 1) {
$jsonQuery = $jsonQuery . ")";
}
}
if (isset($jsonQuery)) {
$query = $query->whereRaw($jsonQuery);
}
if (!empty($param['max_price'])) {
$num = $param['max_price'];

View File

@ -149,8 +149,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'advs/my_advs' => 'Visiosoft\AdvsModule\Http\Controller\advsController@myAdvs',
'advs/my_advs/{params}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@myAdvs',
'advs/edit_advs/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@edit',
'advs/delete_adv/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@destroy',
'advs/status/{id},{type}' => [
'as' => 'visiosoft.module.advs::status',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@statusAds'
@ -166,7 +164,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
],
'mapJson' => 'Visiosoft\AdvsModule\Http\Controller\advsController@mapJson',
'advs/ttr/{id}' => 'Visiosoft\PackagesModule\Http\Controller\packageFEController@advsStatusbyUser',
'advs/delete/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@softDeleteAdv',
'advs/delete/{id}' => [
'as' => 'advs::delete',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@deleteAd',
],
'check_user' => 'Visiosoft\AdvsModule\Http\Controller\advsController@checkUser',
'keySearch' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@keySearch',
'adv/addCart/{id}' => [

View File

@ -339,12 +339,19 @@ class AdvsController extends PublicController
return $location;
}
public function softDeleteAdv(AdvRepositoryInterface $advs, $id)
public function deleteAd(AdvRepositoryInterface $advs, $id)
{
$ad = $this->adv_model->find($id);
if (!Auth::user()) {
redirect('/login?redirect=' . url()->current())->send();
}
if ($ad->created_by_id != Auth::id()) {
$this->messages->error(trans('visiosoft.module.advs::message.delete_author_error'));
}
$advs->softDeleteAdv($id);
$this->messages->error(trans('visiosoft.module.advs::message.success_delete'));
return back();
}
@ -703,18 +710,6 @@ class AdvsController extends PublicController
return $this->view->make('visiosoft.module.advs::new-ad/new-create', compact('id', 'cats_d', 'request', 'Cloudinary', 'cities', 'adv', 'custom_fields'));
}
public function destroy($id)
{
$advs = AdvsAdvsEntryModel::find($id);
if ($advs->id == auth()->user()->id) {
return redirect('/advs/my_advs')->with('success', 'Basariyla Silindi');
} else {
return "Kendinizin olmayan bir ilani silmeye calisiyorsunuz.";
}
}
public function statusAds($id, $type, SettingRepositoryInterface $settings, Dispatcher $events)
{
$ad = $this->adv_model->getAdv($id);

View File

@ -74,6 +74,17 @@ function dropdownRow(id, type) {
passive +
"</a>\n";
}
dropdown += "<a class='dropdown-item text-primary' href='/advs/edit_advs/" + id + "'>" +
"<i class='fas fa-pencil-alt'></i> " +
edit_ad +
"</a>\n";
dropdown += "<a class='dropdown-item text-danger' href='/advs/delete/" + id + "'>" +
"<i class='fas fa-trash'></i> " +
delete_ad +
"</a>\n";
dropdown += "</div></div>";
return dropdown;

View File

@ -6,4 +6,6 @@ return [
'show' => 'Show Adress',
'update_password' => 'Update Password',
'update_profile' => 'Update Profile',
'delete' => 'Delete',
'edit' => 'Edit',
];

View File

@ -6,4 +6,6 @@ return [
'show' => 'Göster',
'update_password' => 'Update Password',
'update_profile' => 'Update Profile',
'delete' => 'Sil',
'edit' => 'Düzenle',
];

View File

@ -51,6 +51,8 @@
<script>
var approve = "{{ trans('visiosoft.module.advs::field.approve') }}";
var passive = "{{ trans('visiosoft.module.advs::field.passive') }}";
var delete_ad = "{{ trans('visiosoft.module.profile::button.delete') }}";
var edit_ad = "{{ trans('visiosoft.module.profile::button.edit') }}";
</script>
{{ asset_add('scripts.js','visiosoft.module.profile::assets/js/ads.js') }}
{% endblock %}