mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #737 from openclassify/dia
#2445 When auto approve is closed, the owner can't see his ad
This commit is contained in:
commit
fdee60440a
@ -13,6 +13,8 @@ use Visiosoft\LocationModule\Country\CountryModel;
|
||||
use Visiosoft\CartsModule\Cart\Command\GetCart;
|
||||
use Visiosoft\LocationModule\District\DistrictModel;
|
||||
use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel;
|
||||
use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface;
|
||||
use Visiosoft\LocationModule\Village\VillageModel;
|
||||
|
||||
class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
{
|
||||
@ -373,6 +375,12 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
return $neighborhood ? $neighborhood->name : false;
|
||||
}
|
||||
|
||||
public function getVillage()
|
||||
{
|
||||
$village = app(VillageRepositoryInterface::class)->find($this->village);
|
||||
return $village ? $village->name : false;
|
||||
}
|
||||
|
||||
public function expired()
|
||||
{
|
||||
return $this->finish_at ? $this->finish_at < Carbon::now() : true;
|
||||
|
||||
@ -451,7 +451,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
public function approveAds($adsIDs)
|
||||
{
|
||||
$defaultAdPublishTime = setting_value('visiosoft.module.advs::default_published_time');
|
||||
$ads = $this->newQuery()->where('advs_advs.id', $adsIDs)->update([
|
||||
$ads = $this->newQuery()->whereIn('advs_advs.id', $adsIDs)->update([
|
||||
'status' => 'approved',
|
||||
'finish_at' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' + ' . $defaultAdPublishTime . ' day')),
|
||||
'publish_at' => date('Y-m-d H:i:s')
|
||||
@ -459,4 +459,14 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
|
||||
return $ads;
|
||||
}
|
||||
|
||||
public function getUserAds($userID = null)
|
||||
{
|
||||
$userID = auth_id_if_null($userID);
|
||||
return $this->newQuery()
|
||||
->where('advs_advs.created_by_id', $userID)
|
||||
->where('status', 'approved')
|
||||
->where('finish_at', '>', date('Y-m-d H:i:s'))
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv\Command;
|
||||
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
|
||||
class GetUserAds
|
||||
{
|
||||
protected $userID;
|
||||
|
||||
public function __construct($userID)
|
||||
{
|
||||
$this->userID = $userID;
|
||||
}
|
||||
|
||||
public function handle(AdvRepositoryInterface $advRepository)
|
||||
{
|
||||
return $advRepository->getUserAds($this->userID);
|
||||
}
|
||||
}
|
||||
@ -4,5 +4,81 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
|
||||
|
||||
interface AdvInterface extends EntryInterface
|
||||
{
|
||||
public function is_enabled($slug);
|
||||
|
||||
public function is_enabled_extension($slug);
|
||||
|
||||
public function is_active($id);
|
||||
|
||||
public function getAdv($id = null, $nullable_ad = false, $trashed = false);
|
||||
|
||||
public function userAdv($nullable_ad = false, $checkRole = true);
|
||||
|
||||
public function getAdvByCat($cat_id);
|
||||
|
||||
public function pendingAdvsByUser();
|
||||
|
||||
public function favsAdvsByUser($fav_ids);
|
||||
|
||||
public function myAdvsByUser();
|
||||
|
||||
public function foreignCurrency($currency, $price, $isUpdate, $settings);
|
||||
|
||||
public function popularAdvs();
|
||||
|
||||
public function advsofDay();
|
||||
|
||||
public function statusAds($id, $status);
|
||||
|
||||
public function finish_at_Ads($id, $endDate);
|
||||
|
||||
public function publish_at_Ads($id);
|
||||
|
||||
public function getLastUserAdv();
|
||||
|
||||
public function getLocationNames($advs);
|
||||
|
||||
public function isAdv($id);
|
||||
|
||||
public function addCart($item, $quantity = 1, $name = null);
|
||||
|
||||
public function getAdvDetailLinkByModel($object, $type = null);
|
||||
|
||||
public function getAdvDetailLinkByAdId($id);
|
||||
|
||||
public function getAdvimage($id);
|
||||
|
||||
public function getLatestField($slug);
|
||||
|
||||
public function updateStock($id, $quantity);
|
||||
|
||||
public function stockControl($id, $quantity);
|
||||
|
||||
public function saveCustomField($category_id, $field_id, $name);
|
||||
|
||||
public function customfields();
|
||||
|
||||
public function priceFormat($adv);
|
||||
|
||||
public function AddAdsDefaultCoverImage($ad);
|
||||
|
||||
public function GetAdsDefaultCoverImageByAdId($id);
|
||||
|
||||
public function viewed_Ad($id);
|
||||
|
||||
public function getRecommended($id);
|
||||
|
||||
public function authControl();
|
||||
|
||||
public function inStock();
|
||||
|
||||
public function getCity();
|
||||
|
||||
public function getDistrict();
|
||||
|
||||
public function getNeighborhood();
|
||||
|
||||
public function getVillage();
|
||||
|
||||
public function expired();
|
||||
}
|
||||
|
||||
@ -46,4 +46,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
||||
public function getPopular();
|
||||
|
||||
public function approveAds($adsIDs);
|
||||
|
||||
public function getUserAds($userID = null);
|
||||
}
|
||||
|
||||
@ -7,9 +7,9 @@ use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
|
||||
use Visiosoft\AdvsModule\Adv\Command\GetAd;
|
||||
use Visiosoft\AdvsModule\Adv\Command\getExchange;
|
||||
use Visiosoft\AdvsModule\Adv\Command\getPopular;
|
||||
use Visiosoft\AdvsModule\Adv\Command\GetUserAds;
|
||||
use Visiosoft\AdvsModule\Adv\Command\isActive;
|
||||
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Currency\Currency;
|
||||
use Visiosoft\AdvsModule\Currency\CurrencyFormat;
|
||||
|
||||
@ -78,6 +78,12 @@ class AdvsModulePlugin extends Plugin
|
||||
->get();
|
||||
}
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'getUserAds',
|
||||
function ($userID = null) {
|
||||
return $this->dispatch(new GetUserAds($userID));
|
||||
}
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'getUserPassiveAdvs',
|
||||
function ($user = null) {
|
||||
|
||||
@ -450,7 +450,7 @@ class AdvsController extends PublicController
|
||||
|
||||
$adv = $this->adv_repository->getListItemAdv($id);
|
||||
|
||||
if ($adv && !$adv->expired()) {
|
||||
if ($adv && (!$adv->expired() || $adv->created_by_id === \auth()->id())) {
|
||||
|
||||
if ($this->adv_model->is_enabled('complaints')) {
|
||||
$complaints = ComplaintsComplainTypesEntryModel::all();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user