hasMany(LineTemplate::class, 'product_platform_id'); } public function productionLines() { return $this->hasMany(LineTemplate::class, 'product_platform_id') ->whereNull('parent_template_id') ->where('line_type', 'production_line') ->orderBy('sort_order'); } public function effectiveCode(): string { return $this->platform_code ?: ($this->auto_code ?? ''); } }