Enth\u00e4lt gemischt: Laravel-10-Upgrade + Phase 1 (Contacts-Modul, Duplicats-Commands, Soft-Delete+Merge-Fields) + Phase 2 Code-Umstellungen (inquiry_id, $table='contacts'/'inquiries') + Offers-Modul (Migrationen, Models, offer_id in Booking, offer-Disk in filesystems.php). Phase 2 + Offers werden im folgenden Commit nach dev/backups/phase2-offers-2026-04-17/ verschoben, damit der Workspace auf Phase-1-only (= Test-System-Stand) reduziert ist und direkt auf Live deploybar wird. Tarball-Backup zus\u00e4tzlich unter: ../backups-safety/workspace-pre-phase1-rollback-2026-04-17.tar.gz Made-with: Cursor
119 lines
No EOL
4.8 KiB
PHP
119 lines
No EOL
4.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Cviebrock\EloquentSluggable\Sluggable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* App\Models\IQContentTree
|
|
*
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $identifier
|
|
* @property string $slug
|
|
* @property string|null $description
|
|
* @property array|null $settings
|
|
* @property int $pos
|
|
* @property int $active
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\IQContentTreeNode[] $iq_content_tree_nodes
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree findSimilarSlugs($attribute, $config, $slug)
|
|
* @method static bool|null forceDelete()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree newQuery()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree onlyTrashed()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree query()
|
|
* @method static bool|null restore()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereActive($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereDeletedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereDescription($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereIdentifier($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree wherePos($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereSettings($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereSlug($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\IQContentTree withoutTrashed()
|
|
* @property int|null $page_id
|
|
* @property int|null $root_id
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree wherePageId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IQContentTree whereRootId($value)
|
|
* @property-read int|null $iq_content_tree_nodes_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|IQContentTree withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class IQContentTree extends Model
|
|
{
|
|
use Sluggable;
|
|
use SoftDeletes;
|
|
|
|
protected $connection = 'mysql_stern';
|
|
|
|
|
|
|
|
protected $table = 'i_q_content_trees';
|
|
|
|
protected $fillable = [
|
|
'name', 'identifier', 'description', 'settings', 'pos', 'active',
|
|
];
|
|
|
|
protected $casts = ['settings' => 'array',
|
|
'deleted_at' => 'datetime',
|
|
];
|
|
|
|
public function sluggable(): array
|
|
{
|
|
return [
|
|
'slug' => [
|
|
'source' => 'name'
|
|
]
|
|
];
|
|
}
|
|
|
|
public function iq_content_tree_nodes()
|
|
{
|
|
return $this->hasMany('App\Models\IQContentTreeNode', 'tree_id', 'id')->orderBy('pos');
|
|
}
|
|
|
|
public function setIdentifierAttribute( $value ) {
|
|
if(!isset($value) || $value == ""){
|
|
$this->attributes['identifier'] = Str::slug(pre_slug($this->name), '-');
|
|
}else{
|
|
$this->attributes['identifier'] = Str::slug(pre_slug($value), '-');
|
|
}
|
|
}
|
|
|
|
|
|
public static function getTreesOptions($id = false, $html = true, $choose = true) {
|
|
|
|
$values = [];
|
|
$ret = "";
|
|
$models = IQContentTree::where('active', 1)->get();
|
|
|
|
if($html) {
|
|
if($choose){
|
|
$ret .= '<option value="">Bitte wählen</option>\n';
|
|
}
|
|
foreach ($models as $model) {
|
|
$attr = ($model->id == $id) ? ' selected="selected"' : '';
|
|
$ret .= '<option value="' . $model->id . '"' . $attr . '>' . $model->name . '</option>\n';
|
|
}
|
|
return $ret;
|
|
}else{
|
|
foreach ($models as $model) {
|
|
$values[$model->id] = $model->name;
|
|
}
|
|
return $values;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} |