belongsTo(Proyecto::class)->findOne(); if ($proyecto) { return $proyecto; } return $this->belongsTo(P::class)->findOne(); } public function inicio() { return Carbon::parse($this->inicio, config('app.timezone')); } public function cierre() { return Carbon::parse($this->cierre, config('app.timezone')); } public function texto() { $text = $this->texto; $text = explode("\n", $text); foreach ($text as &$line) { $line = trim(rtrim($line, '.')) . '.'; if ($line != ltrim($line, '-')) { $line = ' ' . $line; } } $text = implode('
', $text); preg_match_all('/\[\[.*\]\]/', $text, $matches); $search = []; $replace = []; if (count($matches[0]) > 0) { foreach ($matches[0] as $match) { $search []= $match; list($model, $where, $value) = explode(':', str_replace(['[',']'], ['', ''], $match)); $class = '\\Incoviba\\old\\' . $model; $obj = model($class)->where($where, $value)->findOne(); $str = $value; if ($obj->venta()) { $str = '' . $value . ''; } $replace []= $str; } } $text = str_replace($search, $replace, $text); return $text; } } ?>