mirror of
https://github.com/brian8544/turtle-wow.git
synced 2025-01-05 14:24:34 +00:00
40 lines
928 B
PHP
40 lines
928 B
PHP
<?php
|
|
|
|
namespace App\Models\admin;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class Section extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'title',
|
|
'page',
|
|
'section',
|
|
'description',
|
|
'en',
|
|
'zh_cn'
|
|
];
|
|
|
|
public static function getSectionsForPage($page)
|
|
{
|
|
$cacheKey = "dynamicContent." . $page;
|
|
|
|
return Cache::rememberForever($cacheKey, function () use ($page){
|
|
$sections = self::where('page', $page)->where('active', true)->get();
|
|
|
|
|
|
foreach ($sections as $key => $section) {
|
|
$section->en = Blade::render($section->en);
|
|
$section->zh_cn = Blade::render($section->zh_cn);
|
|
}
|
|
|
|
return $sections->keyBy('section');
|
|
});
|
|
}
|
|
}
|