PMCORE-1176

This commit is contained in:
Paula Quispe
2020-10-23 17:32:12 -04:00
committed by Julio Cesar Laura Avendaño
parent 7eeda4ef57
commit 0d32551ca5
14 changed files with 621 additions and 177 deletions

View File

@@ -28,6 +28,19 @@ class Application extends Model
return $this->belongsTo(User::class, 'APP_INIT_USER', 'USR_UID');
}
/**
* Scope for query to get the positive cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopePositivesCases($query)
{
$result = $query->where('APP_NUMBER', '>', 0);
return $result;
}
/**
* Scope for query to get the application by APP_UID.
*
@@ -42,6 +55,20 @@ class Application extends Model
return $result;
}
/**
* Scope for query to get the application by status Id
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $status
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeStatusId($query, int $status)
{
$result = $query->where('APP_STATUS_ID', '=', $status);
return $result;
}
/**
* Scope for query to get the applications by PRO_UID.
*
@@ -111,4 +138,24 @@ class Application extends Model
return $properties;
}
/**
* Get Applications by PRO_UID, ordered by APP_NUMBER.
*
* @param string $proUid
* @param int $status
*
* @return object
* @see ReportTables->populateTable()
*/
public static function getCountByProUid(string $proUid, $status = 2)
{
$query = Application::query()
->select()
->proUid($proUid)
->statusId($status)
->positivesCases();
return $query->get()->count();
}
}