PMCORE-1585

This commit is contained in:
Paula Quispe
2020-06-10 12:15:01 -04:00
parent 0257afebb2
commit 5dbaae523f
9 changed files with 227 additions and 61 deletions

View File

@@ -64,7 +64,7 @@ class Documents extends Model
* Scope a query to filter an specific case
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $proUid
* @param string $appUid
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeAppUid($query, string $appUid)
@@ -72,10 +72,22 @@ class Documents extends Model
return $query->where('APP_UID', $appUid);
}
/**
* Scope a query to filter an specific reference file
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $docId
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeDocId($query, int $docId)
{
return $query->where('DOC_ID', $docId);
}
/**
* Return the documents related to the case
*
* @param int $proId
* @param string $appUid
* @param string $type
*
* @return array
@@ -96,7 +108,9 @@ class Documents extends Model
/**
* Get attached files from the case note.
*
* @param string $appUid
*
* @return object
*/
public static function getAttachedFilesFromTheCaseNote(string $appUid)
@@ -109,4 +123,26 @@ class Documents extends Model
->get();
return $result;
}
/**
* Return the documents related to the specific DOC_ID
*
* @param int $docId
*
* @return array
*/
public static function getFiles(int $docId)
{
$query = Documents::query()->select(['APP_DOC_UID', 'APP_DOC_FILENAME', 'DOC_VERSION']);
$query->docId($docId);
$results = $query->get();
$documentList = [];
$results->each(function ($item, $key) use (&$documentList) {
$row = $item->toArray();
$row['LINK'] = "../cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
$documentList[] = $row;
});
return $documentList;
}
}