Merged in feature/PMCORE-2559 (pull request #7627)
PMCORE-2559 Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
@@ -34,6 +34,7 @@ class AppNotes extends Model
|
||||
*/
|
||||
protected $fillable = [
|
||||
'APP_UID',
|
||||
'APP_NUMBER',
|
||||
'USR_UID',
|
||||
'NOTE_DATE',
|
||||
'NOTE_CONTENT',
|
||||
@@ -57,6 +58,18 @@ class AppNotes extends Model
|
||||
return $query->where('APP_UID', $appUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter an specific case id
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $appNumber
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeAppNumber($query, int $appNumber)
|
||||
{
|
||||
return $query->where('APP_NUMBER', $appNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the documents related to the case
|
||||
*
|
||||
@@ -72,6 +85,7 @@ class AppNotes extends Model
|
||||
$query = AppNotes::query()->select([
|
||||
'NOTE_ID',
|
||||
'APP_UID',
|
||||
'APP_NUMBER',
|
||||
'NOTE_DATE',
|
||||
'NOTE_CONTENT',
|
||||
'NOTE_TYPE',
|
||||
@@ -106,7 +120,7 @@ class AppNotes extends Model
|
||||
*
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return array
|
||||
* @return int
|
||||
*/
|
||||
public static function getTotal(string $appUid)
|
||||
{
|
||||
@@ -116,4 +130,19 @@ class AppNotes extends Model
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total notes by case
|
||||
*
|
||||
* @param int $appNumber
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function total(int $appNumber)
|
||||
{
|
||||
$query = AppNotes::query()->select(['NOTE_ID']);
|
||||
$query->appNumber($appNumber);
|
||||
|
||||
return $query->get()->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,27 @@ class Application extends Model
|
||||
return $firstElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get app number
|
||||
*
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getCaseNumber($appUid)
|
||||
{
|
||||
$query = Application::query()->select(['APP_NUMBER'])
|
||||
->appUid($appUid)
|
||||
->limit(1);
|
||||
$results = $query->get();
|
||||
$caseNumber = 0;
|
||||
$results->each(function ($item) use (&$caseNumber) {
|
||||
$caseNumber = $item->APP_NUMBER;
|
||||
});
|
||||
|
||||
return $caseNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update properties
|
||||
*
|
||||
@@ -164,6 +185,6 @@ class Application extends Model
|
||||
->statusId($status)
|
||||
->positivesCases();
|
||||
|
||||
return $query->get()->count();
|
||||
return $query->get()->count(['APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user