PMCORE-1345
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProcessVariables extends Model
|
||||
{
|
||||
@@ -10,19 +11,89 @@ class ProcessVariables extends Model
|
||||
protected $table = 'PROCESS_VARIABLES';
|
||||
// No timestamps
|
||||
public $timestamps = false;
|
||||
//primary key
|
||||
// Primary key
|
||||
protected $primaryKey = 'VAR_UID';
|
||||
// The IDs are auto-incrementing
|
||||
public $incrementing = false;
|
||||
/**
|
||||
* The model's default values for attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes = [
|
||||
'VAR_FIELD_SIZE' => 0,
|
||||
'VAR_DBCONNECTION' => '',
|
||||
'VAR_SQL' => '',
|
||||
'VAR_NULL' => 0,
|
||||
'VAR_DEFAULT' => '',
|
||||
'VAR_ACCEPTED_VALUES' => '[]',
|
||||
'INP_DOC_UID' => '',
|
||||
];
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'VAR_UID',
|
||||
'PRJ_UID',
|
||||
'PRO_ID',
|
||||
'VAR_NAME',
|
||||
'VAR_FIELD_TYPE',
|
||||
'VAR_FIELD_TYPE_ID',
|
||||
'VAR_FIELD_SIZE',
|
||||
'VAR_LABEL',
|
||||
'VAR_DBCONNECTION',
|
||||
'VAR_SQL',
|
||||
'VAR_NULL',
|
||||
'VAR_DEFAULT',
|
||||
'VAR_ACCEPTED_VALUES',
|
||||
'INP_DOC_UID'
|
||||
];
|
||||
|
||||
/**
|
||||
* Scope a query to filter an specific process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $columns
|
||||
* @param string $proUid
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcess($query, string $proUID)
|
||||
public function scopeProcess($query, string $proUid)
|
||||
{
|
||||
return $query->where('PRJ_UID', $proUID);
|
||||
return $query->where('PRJ_UID', $proUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to filter an specific process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $proId
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcessId($query, int $proId)
|
||||
{
|
||||
return $query->where('PRO_ID', $proId);
|
||||
}
|
||||
/**
|
||||
* Return the variables list
|
||||
*
|
||||
* @param int $proId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getVariables(int $proId)
|
||||
{
|
||||
$query = ProcessVariables::query()->select();
|
||||
$query->leftJoin('DB_SOURCE', function ($join) {
|
||||
$join->on('DB_SOURCE.PRO_ID', '=', 'PROCESS_VARIABLES.PRO_ID');
|
||||
});
|
||||
$query->where('PROCESS_VARIABLES.PRO_ID', $proId);
|
||||
$results = $query->get();
|
||||
$variablesList = [];
|
||||
$results->each(function ($item, $key) use (&$variablesList) {
|
||||
$variablesList[] = $item->toArray();
|
||||
});
|
||||
|
||||
return $variablesList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user