mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
commit
02f21e8e3b
@ -79,13 +79,13 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
$query = $query->whereIn('city', explode(',', array_first($param['city'])));
|
||||
}
|
||||
if (isset($param['district']) and !empty(array_filter($param['district']))) {
|
||||
$query = $query->whereIn('district', explode(',',array_first($param['district'])));
|
||||
$query = $query->whereIn('district', explode(',', array_first($param['district'])));
|
||||
}
|
||||
if (isset($param['neighborhood']) and !empty(array_filter($param['neighborhood']))) {
|
||||
$query = $query->whereIn('neighborhood', explode(',',array_first($param['neighborhood'])));
|
||||
$query = $query->whereIn('neighborhood', explode(',', array_first($param['neighborhood'])));
|
||||
}
|
||||
if (isset($param['village']) and !empty(array_filter($param['village']))) {
|
||||
$query = $query->whereIn('village', explode(',',array_first($param['village'])));
|
||||
$query = $query->whereIn('village', explode(',', array_first($param['village'])));
|
||||
}
|
||||
}
|
||||
if ($category) {
|
||||
@ -147,6 +147,10 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
$query = $query->where('is_get_adv', 1);
|
||||
}
|
||||
|
||||
if (!empty($param['created_at'])) {
|
||||
$query = $query->whereDate('advs_advs.created_at', $param['created_at']);
|
||||
}
|
||||
|
||||
foreach ($param as $para => $value) {
|
||||
if (substr($para, 0, 3) === "cf_") {
|
||||
$id = substr($para, 3);
|
||||
@ -420,7 +424,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
|
||||
foreach ($ads as $index => $ad) {
|
||||
$ads[$index]->detail_url = $this->model->getAdvDetailLinkByModel($ad, 'list');
|
||||
$ads[$index]->currency_price = app(Currency::class)->format($ad->price,$ad->currency);
|
||||
$ads[$index]->currency_price = app(Currency::class)->format($ad->price, $ad->currency);
|
||||
$ads[$index] = $this->model->AddAdsDefaultCoverImage($ad);
|
||||
}
|
||||
|
||||
@ -519,13 +523,17 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
return $ads;
|
||||
}
|
||||
|
||||
public function getUserAds($userID = null)
|
||||
public function getUserAds($userID = null, $status = "approved")
|
||||
{
|
||||
$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'))
|
||||
|
||||
$query = $this->newQuery()
|
||||
->where('advs_advs.created_by_id', $userID);
|
||||
|
||||
if ($status) {
|
||||
$query = $query->where('status', $status);
|
||||
}
|
||||
return $query->where('finish_at', '>', date('Y-m-d H:i:s'))
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,14 +5,16 @@ use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
class GetUserAds
|
||||
{
|
||||
protected $userID;
|
||||
protected $status;
|
||||
|
||||
public function __construct($userID)
|
||||
public function __construct($userID, $status = "approved")
|
||||
{
|
||||
$this->userID = $userID;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function handle(AdvRepositoryInterface $advRepository)
|
||||
{
|
||||
return $advRepository->getUserAds($this->userID);
|
||||
return $advRepository->getUserAds($this->userID, $this->status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,5 +53,5 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
||||
|
||||
public function approveAds($adsIDs);
|
||||
|
||||
public function getUserAds($userID = null);
|
||||
public function getUserAds($userID = null, $status = "approved");
|
||||
}
|
||||
|
||||
@ -73,8 +73,8 @@ class AdvsModulePlugin extends Plugin
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'getUserAds',
|
||||
function ($userID = null) {
|
||||
return $this->dispatch(new GetUserAds($userID));
|
||||
function ($userID = null, $status = "approved") {
|
||||
return $this->dispatch(new GetUserAds($userID, $status));
|
||||
}
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user