✏️ 编辑:StaticPage.php
路径:
/home/boguraj1/.trash/app.1/Models/StaticPage.php
大小:571 B · 修改:2026-07-17 23:32:02 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; class StaticPage extends Model { protected $fillable = ['title', 'slug', 'content', 'is_active']; protected $casts = ['is_active' => 'boolean']; protected static function booted() { static::saving(function ($page) { if (empty($page->slug)) { $page->slug = Str::slug($page->title); } }); } public function getUrlAttribute(): string { return url('/page/' . $this->slug); } }
💾 保存
取消
保存为 UTF-8,换行统一为 LF