1. Go to this page and download the library: Download tbtop/admin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tbtop / admin example snippets
class PostsIndexPage extends Page
{
public static function path(): string { return 'posts'; }
public static function nav(): ?array
{
return ['group' => 'Content', 'label' => 'Posts', 'order' => 1];
}
public function view(S $s): Node
{
return $s->stack([
$s->table('posts')
->columns(['title' => 'Title', 'views' => 'Views'])
->searchable(['title'])
->defaultSort('created_at', 'desc')
->query(fn () => Post::query())
->rowActions([
$s->action('edit')->label('Edit')
->visit('/admin/posts/{row.id}/edit'), // row template
$s->action('delete')->label('Delete')->color('danger')
->confirm('Delete this post?')
->handle(function (ActionCtx $ctx): Effects {
Post::whereKey($ctx->row['id'])->delete();
return Effects::make()->notify('Deleted')->refreshTable();
}, needs: ['row']),
])
->toNode(),
]);
}
}
bash
cd packages/php && vendor/bin/pest && vendor/bin/phpstan analyse && vendor/bin/pint --test
cd packages/client && bun test && bunx tsc --noEmit
cd apps/demo && php artisan test
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.