fix: splits monitor widget types to complete and active
This commit is contained in:
@@ -16,6 +16,9 @@ final class MonitorList extends AbstractController
|
||||
|
||||
use PaginateTrait;
|
||||
|
||||
#[LiveProp(writable: true)]
|
||||
public string $type;
|
||||
|
||||
#[LiveProp(writable: true)]
|
||||
public bool $isWidget = true;
|
||||
|
||||
@@ -24,8 +27,34 @@ final class MonitorList extends AbstractController
|
||||
) {}
|
||||
|
||||
#[LiveAction]
|
||||
public function getUserMonitors()
|
||||
public function getMonitors()
|
||||
{
|
||||
return $this->monitorRepository->getUserMonitorsPaginated($this->getUser(), $this->pageNumber, $this->perPage);
|
||||
if ($this->type === "active") {
|
||||
return $this->getActiveUserMonitors();
|
||||
} elseif ($this->type === "complete") {
|
||||
return $this->getCompleteUserMonitors();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
#[LiveAction]
|
||||
public function getActiveUserMonitors()
|
||||
{
|
||||
return $this->asPaginator($this->monitorRepository->createQueryBuilder('m')
|
||||
->andWhere('m.status IN (:statuses)')
|
||||
->setParameter('statuses', ['New', 'In Progress'])
|
||||
->getQuery()
|
||||
);
|
||||
}
|
||||
|
||||
#[LiveAction]
|
||||
public function getCompleteUserMonitors()
|
||||
{
|
||||
return $this->asPaginator($this->monitorRepository->createQueryBuilder('m')
|
||||
->andWhere('m.status = :status')
|
||||
->setParameter('status', 'Complete')
|
||||
->getQuery()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user