PMCORE-3083

This commit is contained in:
Paula Quispe
2021-07-08 12:55:24 -04:00
parent 072b06d899
commit bb9e6b77b2
17 changed files with 439 additions and 43 deletions

View File

@@ -7,7 +7,7 @@ use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\TaskScheduler::class, function (Faker $faker) {
return [
'id' => G::generateUniqueID(),
'id' => $faker->unique()->numberBetween(5000),
'title' => $faker->title,
'startingTime' => $faker->dateTime(),
'endingTime' => $faker->dateTime(),

View File

@@ -156,6 +156,49 @@ class DraftTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_filter_by_specific_cases()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$draft = new Draft();
$draft->setUserId($cases['USR_ID']);
$draft->setCasesNumbers([$cases['APP_NUMBER']]);
$draft->setOrderByColumn('APP_NUMBER');
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_filter_by_range_cases()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$draft = new Draft();
$draft->setUserId($cases['USR_ID']);
$rangeOfCases = $cases['APP_NUMBER'] . "-" . $cases['APP_NUMBER'];
$draft->setRangeCasesFromTo([$rangeOfCases]);
$draft->setOrderByColumn('APP_NUMBER');
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with taskId filter
*

View File

@@ -150,6 +150,49 @@ class InboxTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_filter_by_specific_cases()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$inbox->setCasesNumbers([$cases->APP_NUMBER]);
$inbox->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_filter_by_range_cases()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$rangeOfCases = $cases->APP_NUMBER . "-" . $cases->APP_NUMBER;
$inbox->setRangeCasesFromTo([$rangeOfCases]);
$inbox->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with taskId filter
*

View File

@@ -116,6 +116,7 @@ class ParticipatedTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setCaseStatus()
* @test
*/
public function it_filter_by_started_by_me()
@@ -128,6 +129,8 @@ class ParticipatedTest extends TestCase
$participated->setUserUid($cases->USR_UID);
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Get only the TO_DO
$participated->setCaseStatus(2);
// Set the filter STARTED
$participated->setParticipatedStatus('STARTED');
// Set OrderBYColumn value
@@ -172,6 +175,7 @@ class ParticipatedTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setProcessId()
* @test
*/
public function it_filter_by_process()
@@ -196,12 +200,76 @@ class ParticipatedTest extends TestCase
$this->assertEquals(2, count($res));
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setCasesNumbers()
* @test
*/
public function it_filter_by_specific_cases()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// Create new Participated object
$participated = new Participated();
// Set the filter
$participated->setFilterCases('STARTED');
// Set the user UID
$participated->setUserUid($cases['USR_UID']);
// Set the user ID
$participated->setUserId($cases['USR_ID']);
// Set the case numbers
$participated->setCasesNumbers([$cases['APP_NUMBER']]);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(2, count($res));
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_range_cases()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// Create new Participated object
$participated = new Participated();
// Set the filter
$participated->setFilterCases('STARTED');
// Set the user UID
$participated->setUserUid($cases['USR_UID']);
// Set the user ID
$participated->setUserId($cases['USR_ID']);
// Set the range of case numbers
$rangeOfCases = $cases['APP_NUMBER'] . "-" . $cases['APP_NUMBER'];
$participated->setRangeCasesFromTo([$rangeOfCases]);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(2, count($res));
}
/**
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setCaseTitle()
* @test
*/
public function it_filter_by_thread_title()

View File

@@ -241,6 +241,32 @@ class PausedTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_filter_by_specific_cases()
{
// Create factories related to the paused cases
$cases = $this->createPaused();
//Create new Paused object
$paused = new Paused();
//Set the user UID
$paused->setUserUid($cases->USR_UID);
//Set the user ID
$paused->setUserId($cases->USR_ID);
//Set app number
$paused->setCasesNumbers([$cases->APP_NUMBER]);
//Call to getData method
$res = $paused->getData();
//This asserts there are results for the filtered app number
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with taskId filter
*

View File

@@ -351,11 +351,11 @@ class SupervisingTest extends TestCase
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
//Set the user UID
// Set the user UID
$Supervising->setUserUid($cases->USR_UID);
//Set the user ID
// Set the user ID
$Supervising->setUserId($cases->USR_ID);
//Call the getData method
// Call the getData method
$res = $Supervising->getData();
// Asserts the result contains 3 registers
$this->assertCount(3, $res);
@@ -373,11 +373,11 @@ class SupervisingTest extends TestCase
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
//Set the user UID
// Set the user UID
$Supervising->setUserUid($user->USR_UID);
//Set the user ID
// Set the user ID
$Supervising->setUserId($user->USR_ID);
//Call the getData method
// Call the getData method
$res = $Supervising->getData();
// Asserts the result
$this->assertEmpty($res);
@@ -394,13 +394,13 @@ class SupervisingTest extends TestCase
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
//Set the user UID
// Set the user UID
$Supervising->setUserUid($cases->USR_UID);
//Set the user ID
// Set the user ID
$Supervising->setUserId($cases->USR_ID);
//Call the getCounter method
// Call the getCounter method
$res = $Supervising->getCounter();
//Assert the counter
// Assert the counter
$this->assertEquals(3, $res);
}
@@ -410,6 +410,7 @@ class SupervisingTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setCaseNumber()
* @test
*/
public function it_filter_by_app_number()
@@ -417,16 +418,74 @@ class SupervisingTest extends TestCase
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
//Set the user UID
// Set the user UID
$Supervising->setUserUid($cases->USR_UID);
//Set the user ID
// Set the user ID
$Supervising->setUserId($cases->USR_ID);
// Set the case number
$Supervising->setCaseNumber($cases->APP_NUMBER);
//Call the getData method
// Call the getData method
$res = $Supervising->getData();
// Asserts the result contains 3 registers
$this->assertCount(1, $res);
//Asserts that the result contains the app number searched
// Asserts that the result contains the app number searched
$this->assertContains($cases->APP_NUMBER, $res[0]);
}
/**
* Tests the filter by APP_NUMBER
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setCaseNumber()
* @test
*/
public function it_filter_by_specific_cases()
{
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
// Set the user UID
$Supervising->setUserUid($cases->USR_UID);
// Set the user ID
$Supervising->setUserId($cases->USR_ID);
// Set the case numbers
$Supervising->setCasesNumbers([$cases->APP_NUMBER]);
// Call the getData method
$res = $Supervising->getData();
// Asserts the result contains 3 registers
$this->assertCount(1, $res);
// Asserts that the result contains the app number searched
$this->assertContains($cases->APP_NUMBER, $res[0]);
}
/**
* Tests the filter by APP_NUMBER
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_range_cases()
{
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
// Set the user UID
$Supervising->setUserUid($cases->USR_UID);
// Set the user ID
$Supervising->setUserId($cases->USR_ID);
// Set the range of case numbers
$rangeOfCases = $cases->APP_NUMBER . "-" . $cases->APP_NUMBER;
$Supervising->setRangeCasesFromTo([$rangeOfCases]);
// Call the getData method
$res = $Supervising->getData();
// Asserts the result contains 3 registers
$this->assertCount(1, $res);
// Asserts that the result contains the app number searched
$this->assertContains($cases->APP_NUMBER, $res[0]);
}
@@ -436,6 +495,7 @@ class SupervisingTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setProcessId()
* @test
*/
public function it_filter_by_process()
@@ -460,6 +520,7 @@ class SupervisingTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setTaskId()
* @test
*/
public function it_filter_by_task()
@@ -484,6 +545,7 @@ class SupervisingTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setCaseTitle()
* @test
*/
public function it_filter_by_thread_title()
@@ -515,6 +577,7 @@ class SupervisingTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setOrderByColumn()
* @test
*/
public function it_order_by_column()

View File

@@ -1260,6 +1260,10 @@ class AbstractCases implements CasesInterface
if (!empty($properties['caseNumber'])) {
$this->setCaseNumber($properties['caseNumber']);
}
// Add a filter with specific cases or range of cases like '1, 3-5, 8, 10-15'
if (!empty($properties['filterCases'])) {
$this->setFilterCases($properties['filterCases']);
}
// Filter by case title
if (!empty($properties['caseTitle'])) {
$this->setCaseTitle($properties['caseTitle']);
@@ -1290,10 +1294,6 @@ class AbstractCases implements CasesInterface
$this->setFinishCaseTo($properties['finishCaseTo']);
}
/** Apply filters related to SEARCH */
// Add a filter with specific cases or range of cases like '1, 3-5, 8, 10-15'
if (get_class($this) === Search::class && !empty($properties['filterCases'])) {
$this->setFilterCases($properties['filterCases']);
}
// Filter by more than one case statuses like ['DRAFT', 'TO_DO']
if (get_class($this) === Search::class && !empty($properties['caseStatuses'])) {
$this->setCaseStatuses($properties['caseStatuses']);

View File

@@ -47,6 +47,18 @@ class Draft extends AbstractCases
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Filter only cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers()) && empty($this->getRangeCasesFromTo())) {
$query->specificCases($this->getCasesNumbers());
}
// Filter only cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo()) && empty($this->getCasesNumbers())) {
$query->rangeOfCases($this->getRangeCasesFromTo());
}
// Filter cases mixed by range of cases and specific cases like '1,3-5,8'
if (!empty($this->getCasesNumbers()) && !empty($this->getRangeCasesFromTo())) {
$query->casesOrRangeOfCases($this->getCasesNumbers(), $this->getRangeCasesFromTo());
}
// Specific case title
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());

View File

@@ -50,6 +50,18 @@ class Inbox extends AbstractCases
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Filter only cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers()) && empty($this->getRangeCasesFromTo())) {
$query->specificCases($this->getCasesNumbers());
}
// Filter only cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo()) && empty($this->getCasesNumbers())) {
$query->rangeOfCases($this->getRangeCasesFromTo());
}
// Filter cases mixed by range of cases and specific cases like '1,3-5,8'
if (!empty($this->getCasesNumbers()) && !empty($this->getRangeCasesFromTo())) {
$query->casesOrRangeOfCases($this->getCasesNumbers(), $this->getRangeCasesFromTo());
}
// Specific case title
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());

View File

@@ -52,6 +52,18 @@ class Participated extends AbstractCases
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Filter only cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers()) && empty($this->getRangeCasesFromTo())) {
$query->specificCases($this->getCasesNumbers());
}
// Filter only cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo()) && empty($this->getCasesNumbers())) {
$query->rangeOfCases($this->getRangeCasesFromTo());
}
// Filter cases mixed by range of cases and specific cases like '1,3-5,8'
if (!empty($this->getCasesNumbers()) && !empty($this->getRangeCasesFromTo())) {
$query->casesOrRangeOfCases($this->getCasesNumbers(), $this->getRangeCasesFromTo());
}
// Specific case title
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());

View File

@@ -49,6 +49,18 @@ class Paused extends AbstractCases
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Filter only cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers()) && empty($this->getRangeCasesFromTo())) {
$query->specificCases($this->getCasesNumbers());
}
// Filter only cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo()) && empty($this->getCasesNumbers())) {
$query->rangeOfCases($this->getRangeCasesFromTo());
}
// Filter cases mixed by range of cases and specific cases like '1,3-5,8'
if (!empty($this->getCasesNumbers()) && !empty($this->getRangeCasesFromTo())) {
$query->casesOrRangeOfCases($this->getCasesNumbers(), $this->getRangeCasesFromTo());
}
// Specific case title
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());

View File

@@ -48,14 +48,18 @@ class Search extends AbstractCases
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Filter cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers())) {
// Filter only cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers()) && empty($this->getRangeCasesFromTo())) {
$query->specificCases($this->getCasesNumbers());
}
// Filter cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo())) {
// Filter only cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo()) && empty($this->getCasesNumbers())) {
$query->rangeOfCases($this->getRangeCasesFromTo());
}
// Filter cases mixed by range of cases and specific cases like '1,3-5,8'
if (!empty($this->getCasesNumbers()) && !empty($this->getRangeCasesFromTo())) {
$query->casesOrRangeOfCases($this->getCasesNumbers(), $this->getRangeCasesFromTo());
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// Join with delegation

View File

@@ -49,6 +49,18 @@ class Supervising extends AbstractCases
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Filter only cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers()) && empty($this->getRangeCasesFromTo())) {
$query->specificCases($this->getCasesNumbers());
}
// Filter only cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo()) && empty($this->getCasesNumbers())) {
$query->rangeOfCases($this->getRangeCasesFromTo());
}
// Filter cases mixed by range of cases and specific cases like '1,3-5,8'
if (!empty($this->getCasesNumbers()) && !empty($this->getRangeCasesFromTo())) {
$query->casesOrRangeOfCases($this->getCasesNumbers(), $this->getRangeCasesFromTo());
}
// Specific case title
if (!empty($this->getCaseTitle())) {
$query->title($this->getCaseTitle());

View File

@@ -50,6 +50,18 @@ class Unassigned extends AbstractCases
if ($this->getCaseNumber()) {
$query->case($this->getCaseNumber());
}
// Filter only cases by specific cases like [1,3,5]
if (!empty($this->getCasesNumbers()) && empty($this->getRangeCasesFromTo())) {
$query->specificCases($this->getCasesNumbers());
}
// Filter only cases by range of cases like ['1-5', '10-15']
if (!empty($this->getRangeCasesFromTo()) && empty($this->getCasesNumbers())) {
$query->rangeOfCases($this->getRangeCasesFromTo());
}
// Filter cases mixed by range of cases and specific cases like '1,3-5,8'
if (!empty($this->getCasesNumbers()) && !empty($this->getRangeCasesFromTo())) {
$query->casesOrRangeOfCases($this->getCasesNumbers(), $this->getRangeCasesFromTo());
}
// Specific case title
if ($this->getCaseTitle()) {
$query->title($this->getCaseTitle());

View File

@@ -135,18 +135,49 @@ class Application extends Model
*/
public function scopeRangeOfCases($query, array $rangeCases)
{
foreach ($rangeCases as $fromTo) {
$fromTo = explode("-", $fromTo);
if (count($fromTo) === 2) {
$from = $fromTo[0];
$to = $fromTo[1];
if ($to > $from) {
$query->orWhere(function ($query) use ($from, $to) {
$query->casesFrom($from)->casesTo($to);
});
$query->where(function ($query) use ($rangeCases) {
foreach ($rangeCases as $fromTo) {
$fromTo = explode("-", $fromTo);
if (count($fromTo) === 2) {
$from = $fromTo[0];
$to = $fromTo[1];
if ($to > $from) {
$query->orWhere(function ($query) use ($from, $to) {
$query->casesFrom($from)->casesTo($to);
});
}
}
}
}
});
}
/**
* Scope more than one range of cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $cases
* @param array $rangeCases
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCasesOrRangeOfCases($query, array $cases, array $rangeCases)
{
$query->where(function ($query) use ($cases, $rangeCases) {
// Get the cases related to the task self service
$query->specificCases($cases);
foreach ($rangeCases as $fromTo) {
$fromTo = explode("-", $fromTo);
if (count($fromTo) === 2) {
$from = $fromTo[0];
$to = $fromTo[1];
if ($to > $from) {
$query->orWhere(function ($query) use ($from, $to) {
$query->casesFrom($from)->casesTo($to);
});
}
}
}
});
}
/**

View File

@@ -488,18 +488,49 @@ class Delegation extends Model
*/
public function scopeRangeOfCases($query, array $rangeCases)
{
foreach ($rangeCases as $fromTo) {
$fromTo = explode("-", $fromTo);
if (count($fromTo) === 2) {
$from = $fromTo[0];
$to = $fromTo[1];
if ($to > $from) {
$query->orWhere(function ($query) use ($from, $to) {
$query->casesFrom($from)->casesTo($to);
});
$query->where(function ($query) use ($rangeCases) {
foreach ($rangeCases as $fromTo) {
$fromTo = explode("-", $fromTo);
if (count($fromTo) === 2) {
$from = $fromTo[0];
$to = $fromTo[1];
if ($to > $from) {
$query->orWhere(function ($query) use ($from, $to) {
$query->casesFrom($from)->casesTo($to);
});
}
}
}
}
});
}
/**
* Scope more than one range of cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $cases
* @param array $rangeCases
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCasesOrRangeOfCases($query, array $cases, array $rangeCases)
{
$query->where(function ($query) use ($cases, $rangeCases) {
// Get the cases related to the task self service
$query->specificCases($cases);
foreach ($rangeCases as $fromTo) {
$fromTo = explode("-", $fromTo);
if (count($fromTo) === 2) {
$from = $fromTo[0];
$to = $fromTo[1];
if ($to > $from) {
$query->orWhere(function ($query) use ($from, $to) {
$query->casesFrom($from)->casesTo($to);
});
}
}
}
});
}
/**

View File

@@ -50,6 +50,7 @@ class Home extends Api
* @param int $process
* @param int $task
* @param string $caseTitle
* @param string $filterCases
* @param string $paged
* @param string $sort
*
@@ -65,6 +66,7 @@ class Home extends Api
int $process = 0,
int $task = 0,
string $caseTitle = '',
string $filterCases = '',
string $paged = '0,15',
string $sort = 'APP_NUMBER,DESC'
) {
@@ -74,6 +76,7 @@ class Home extends Api
$properties = [];
$properties['caseNumber'] = $caseNumber;
$properties['caseTitle'] = $caseTitle;
$properties['filterCases'] = $filterCases;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -105,6 +108,7 @@ class Home extends Api
* @param int $process
* @param int $task
* @param string $caseTitle
* @param string $filterCases
* @param string $paged
* @param string $sort
*
@@ -120,6 +124,7 @@ class Home extends Api
int $process = 0,
int $task = 0,
string $caseTitle = '',
string $filterCases = '',
string $paged = '0,15',
string $sort = 'APP_NUMBER,DESC'
) {
@@ -129,6 +134,7 @@ class Home extends Api
$properties = [];
$properties['caseNumber'] = $caseNumber;
$properties['caseTitle'] = $caseTitle;
$properties['filterCases'] = $filterCases;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -160,6 +166,7 @@ class Home extends Api
* @param int $process
* @param int $task
* @param string $caseTitle
* @param string $filterCases
* @param string $paged
* @param string $sort
*
@@ -175,6 +182,7 @@ class Home extends Api
int $process = 0,
int $task = 0,
string $caseTitle = '',
string $filterCases = '',
string $paged = '0,15',
string $sort = 'APP_NUMBER,DESC'
) {
@@ -184,6 +192,7 @@ class Home extends Api
$properties = [];
$properties['caseNumber'] = $caseNumber;
$properties['caseTitle'] = $caseTitle;
$properties['filterCases'] = $filterCases;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -217,6 +226,7 @@ class Home extends Api
* @param int $process
* @param int $task
* @param string $caseTitle
* @param string $filterCases
* @param string $paged
* @param string $sort
*
@@ -232,6 +242,7 @@ class Home extends Api
int $process = 0,
int $task = 0,
string $caseTitle = '',
string $filterCases = '',
string $paged = '0,15',
string $sort = 'APP_NUMBER,DESC'
) {
@@ -241,6 +252,7 @@ class Home extends Api
$properties = [];
$properties['caseNumber'] = $caseNumber;
$properties['caseTitle'] = $caseTitle;
$properties['filterCases'] = $filterCases;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API
@@ -272,6 +284,7 @@ class Home extends Api
* @param int $process
* @param int $task
* @param string $caseTitle
* @param string $filterCases
* @param string $filter
* @param string $caseStatus
* @param string $startCaseFrom
@@ -293,6 +306,7 @@ class Home extends Api
int $process = 0,
int $task = 0,
string $caseTitle = '',
string $filterCases = '',
string $filter = 'IN_PROGRESS',
string $caseStatus = '',
string $startCaseFrom = '',
@@ -306,6 +320,7 @@ class Home extends Api
$properties = [];
$properties['caseNumber'] = $caseNumber;
$properties['caseTitle'] = $caseTitle;
$properties['filterCases'] = $filterCases;
$properties['process'] = $process;
$properties['task'] = $task;
// Get the user that access to the API