feat: add admin env badge, quick post button, and harden plugin enable
Build and Deploy / verify (push) Failing after 15m17s
Build and Deploy / deploy (push) Skipped

Show local/prod in the Filament topbar, jump to create post in one click, tighten sidebar spacing, and stop Hello World from 500ing when its tables are missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
gouki
2026-09-18 08:24:16 +00:00
co-authored by Cursor
parent b39423831c
commit 469160dc3f
19 changed files with 825 additions and 43 deletions
@@ -24,6 +24,8 @@ class HelloWorldSettings extends Page
protected static ?string $title = 'Hello World 设置';
protected static ?string $slug = 'hello-world-settings';
protected string $view = 'filament.pages.plugin-settings';
public array $data = [];
@@ -15,7 +15,9 @@ class HelloWorldController
*/
public function index()
{
$logs = HelloWorldLog::query()->with('comment')->latest()->limit(10)->get();
$logs = \Illuminate\Support\Facades\Schema::hasTable('hello_world_logs')
? HelloWorldLog::query()->with('comment')->latest()->limit(10)->get()
: collect();
$view = view('demo-hello::hello', ['logs' => $logs]);
app(\App\Blog\View\Composers\SidebarComposer::class)->compose($view);
@@ -29,15 +29,21 @@ class ServiceProvider extends PluginServiceProvider
$manager->addFilter('post.rendered', function (string $html, Post $post) {
$greeting = (string) Setting::get('hello_world_greeting', '你好');
return preg_replace_callback(
'/\[hello\s+([^\]]+)\]/',
$replaced = preg_replace_callback(
'/\[hello\s+([^\]]+)\]/u',
fn (array $m) => '<span class="hello-world">'.$greeting.','.e($m[1]).'!</span>',
$html
);
return is_string($replaced) ? $replaced : $html;
}, 20);
// 4. 动作示例:新评论创建时写日志(演示数据关联 + 钩子监听)
$manager->addAction('comment.created', function (Comment $comment) {
if (! \Illuminate\Support\Facades\Schema::hasTable('hello_world_logs')) {
return;
}
HelloWorldLog::create([
'comment_id' => $comment->id,
'note' => '捕获新评论:'.mb_substr($comment->content, 0, 30),