PMCORE-3709
This commit is contained in:
@@ -32,6 +32,34 @@ class AdditionalTables extends Model
|
||||
return $query->where('ADD_TAB_OFFLINE', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the tables related to the process
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $proUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcess($query, string $proUid)
|
||||
{
|
||||
return $query->where('PRO_UID', $proUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tables related to the process
|
||||
*
|
||||
* @param string $proUid
|
||||
* @return array
|
||||
*/
|
||||
public static function getTables(string $proUid)
|
||||
{
|
||||
$query = AdditionalTables::query()->select();
|
||||
$query->process($proUid);
|
||||
$result = $query->get()->values()->toArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure of offline tables
|
||||
*
|
||||
|
||||
@@ -32,6 +32,39 @@ class Fields extends Model
|
||||
return $query->where('ADD_TAB_UID', '=', $tabUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the field name
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $name
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeField($query, $name)
|
||||
{
|
||||
return $query->where('FLD_NAME', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the field name or label name
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $field
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeFieldOrLabel($query, $field)
|
||||
{
|
||||
$query->where(function ($query) use ($field) {
|
||||
$query->field($field);
|
||||
$fieldLabel = $field . '_label';
|
||||
$query->orWhere(function ($query) use ($fieldLabel) {
|
||||
$query->field($fieldLabel);
|
||||
});
|
||||
});
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offline tables
|
||||
*
|
||||
@@ -52,4 +85,22 @@ class Fields extends Model
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a field related to the table
|
||||
*
|
||||
* @param string $tabUid
|
||||
* @param string $field
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function searchVariable(string $tabUid, string $field)
|
||||
{
|
||||
$query = Fields::query();
|
||||
$query->table($tabUid);
|
||||
$query->fieldOrLabel($field);
|
||||
$result = $query->get()->values()->toArray();
|
||||
|
||||
return !empty($result);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,23 @@ class ProcessVariables extends Model
|
||||
return $query->where('VAR_FIELD_TYPE_ID', $typeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the variable information
|
||||
*
|
||||
* @param string $varUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getVariable(string $varUid)
|
||||
{
|
||||
$query = ProcessVariables::query()->select();
|
||||
$query->where('VAR_UID', $varUid)->limit(1);
|
||||
$result = $query->get()->values()->toArray();
|
||||
$result = head($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the variables list
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user