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