08 2024
This commit is contained in:
parent
c1c613a4b9
commit
881fc84207
384 changed files with 50679 additions and 990 deletions
|
|
@ -85,4 +85,52 @@ class Arrangement extends Model
|
|||
{
|
||||
return $this->belongsTo(ArrangementTemplate::class, 'template_id');
|
||||
}
|
||||
|
||||
public function arrangement_type()
|
||||
{
|
||||
return $this->belongsTo(ArrangementType::class, 'type_id');
|
||||
}
|
||||
|
||||
public function getDataAsMap()
|
||||
{
|
||||
$rawData = $this->attributes['data_s'];
|
||||
$data = json_decode('{'. $rawData .'}', true);
|
||||
if (is_array($data))
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
$entries = preg_split("/[\r\n;]+\s*/", $rawData, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$ret = array();
|
||||
foreach ($entries as $entry)
|
||||
{
|
||||
$map = preg_split('/:\s*/', $entry, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (count($map) == 2)
|
||||
{
|
||||
$ret[$map[0]] = $map[1];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getDataS()
|
||||
{
|
||||
$rawData = $this->attributes['data_s'];
|
||||
$data = json_decode('{'. $rawData .'}', true);
|
||||
if (is_array($data))
|
||||
{
|
||||
$str = '';
|
||||
$i = 0;
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
if (++$i > 0)
|
||||
{
|
||||
$str .= '';
|
||||
}
|
||||
$str .= $k .' '. $v;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
return $rawData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue