mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 23:06:08 -06:00
commit
02f21e8e3b
@ -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);
|
||||||
@ -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