初始化

This commit is contained in:
2026-08-08 18:27:38 +08:00
parent efc150c937
commit 060eb79c09
336 changed files with 24613 additions and 15 deletions
+89
View File
@@ -0,0 +1,89 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Solution extends Model
{
use SoftDeletes;
protected $fillable = [
'name',
'slug',
'power_segment',
'application',
'chip_platform',
'power',
'summary',
'advantages',
'description',
'cover',
'status',
'sort',
'seo_title',
'seo_description',
];
public const POWER_SEGMENTS = [
'lt30' => '30W 以下',
'30-65' => '3065W',
'65-100' => '65100W',
'gt100' => '100W 以上',
];
public const APPLICATIONS = [
'charger' => '充电器',
'powerbank' => '移动电源',
'car' => '车载充电',
'dock' => '扩展坞 / 多口排插',
];
public const CHIP_PLATFORMS = [
'protocol' => '协议芯片',
'soc' => '高集成 SoC',
'rectifier' => '同步整流',
];
public function scopePublished($query)
{
return $query->where('status', 'published')->orderBy('sort')->orderBy('name');
}
public function powerSegmentLabel(): string
{
return self::POWER_SEGMENTS[$this->power_segment] ?? $this->power_segment ?? '—';
}
public function applicationLabel(): string
{
return self::APPLICATIONS[$this->application] ?? $this->application ?? '—';
}
public function chipPlatformLabel(): string
{
return self::CHIP_PLATFORMS[$this->chip_platform] ?? $this->chip_platform ?? '—';
}
public function advantagesList(): array
{
if (! $this->advantages) {
return [];
}
return collect(explode("\n", $this->advantages))
->map(fn ($line) => trim($line))
->filter()
->all();
}
public function seoTitle(): string
{
return $this->seo_title ?: ($this->name . ' - 深圳市云创芯电子有限公司');
}
public function seoDescription(): string
{
return $this->seo_description ?: ($this->summary ?: $this->name);
}
}