fix add remove error

This commit is contained in:
vedatakd 2020-06-26 14:02:35 +03:00
parent d9c3d34118
commit 7429db5768
5 changed files with 13 additions and 17 deletions

View File

@ -22,4 +22,5 @@ return [
'currency_converted' => 'Currency Converted Successfully.', 'currency_converted' => 'Currency Converted Successfully.',
'choose_user' => 'Choose a user', 'choose_user' => 'Choose a user',
'owner_updated_successfully' => 'The Owner Has Been Updated Successfully!', 'owner_updated_successfully' => 'The Owner Has Been Updated Successfully!',
'no_add_found' => 'No Ad Found!',
]; ];

View File

@ -340,12 +340,6 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$adv->update(['cover_photo' => $coverPhoto]); $adv->update(['cover_photo' => $coverPhoto]);
} }
public function delete_empty_advs()
{
AdvsAdvsEntryModel::query()->where('slug', "")->forceDelete();
DB::table('advs_advs_translations')->where('name', NULL)->delete();
}
public function getRecommendedAds($id) public function getRecommendedAds($id)
{ {
return AdvModel::query() return AdvModel::query()
@ -364,7 +358,9 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
public function getAdvArray($id) public function getAdvArray($id)
{ {
return AdvsAdvsEntryModel::query()->where('advs_advs.id', $id)->first()->toArray(); $ad = AdvsAdvsEntryModel::query()->where('advs_advs.id', $id)->first();
return ($ad !== null) ? $ad->toArray() : null;
} }
public function getQuantity($quantity, $type, $item) public function getQuantity($quantity, $type, $item)

View File

@ -20,8 +20,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function cover_image_update($adv); public function cover_image_update($adv);
public function delete_empty_advs();
public function getRecommendedAds($id); public function getRecommendedAds($id);
public function getLastAd($id); public function getLastAd($id);

View File

@ -567,11 +567,10 @@ class AdvsController extends PublicController
$adv = AdvsAdvsEntryModel::find($request->update_id); $adv = AdvsAdvsEntryModel::find($request->update_id);
if ($advModel->is_enabled('packages') and $adv->slug == "") { if ($advModel->is_enabled('packages') and $adv->slug == "") {
$cat = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForNewAd($request); $cat = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForNewAd($request);
if(!is_null($cat)) if (!is_null($cat)) {
{ return redirect('/');
return redirect('/'); }
}
} }
// Create options // Create options
@ -695,6 +694,11 @@ class AdvsController extends PublicController
$isActive = new AdvModel(); $isActive = new AdvModel();
$adv = $advRepository->getAdvArray($id); $adv = $advRepository->getAdvArray($id);
if (is_null($adv)) {
$this->messages->error(trans('visiosoft.module.advs::message.no_add_found'));
return $this->redirect->to(route('advs::create_adv'));
}
if ($adv['created_by_id'] != auth()->id() if ($adv['created_by_id'] != auth()->id()
&& !auth()->user()->hasPermission('visiosoft.module.advs::advs.write')) { && !auth()->user()->hasPermission('visiosoft.module.advs::advs.write')) {
abort(403); abort(403);

View File

@ -50,9 +50,6 @@ class MyProfileController extends PublicController
public function home(ProfileFormBuilder $form, AdvRepositoryInterface $advRepository) public function home(ProfileFormBuilder $form, AdvRepositoryInterface $advRepository)
{ {
//clear empty ads
$advRepository->delete_empty_advs();
$advs_count = new AdvModel(); $advs_count = new AdvModel();
$advs_count = count($advs_count->myAdvsByUser()->get()); $advs_count = count($advs_count->myAdvsByUser()->get());