PHP code example of rafalmasiarek / dashboard-kit-addon-content

1. Go to this page and download the library: Download rafalmasiarek/dashboard-kit-addon-content 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/ */

    

rafalmasiarek / dashboard-kit-addon-content example snippets


return [
    'title' => 'Pages',
    'icon'  => '📄',
    'content' => [
        'table'  => 'pages',               // optional; omit to auto-create content_{slug}
        'list'   => ['title', 'status'],   // columns shown in the admin list view
        'fields' => [
            'title'  => ['type' => 'text',     'label' => 'Title',   '

'hooks' => [
    'before_create' => function (array $data): array { return $data; },
    'before_update' => function (array $data, array $existing): array { return $data; },
    'after_create'  => function (int $id, array $data): void {},
    'after_update'  => function (int $id, array $data): void {},
    'before_delete' => function (int $id, array $existing): void {},
    'after_delete'  => function (int $id): void {},
],

use rafalmasiarek\DashboardKitContent\ContentRepository;

$repo = $container->get(ContentRepository::class);

$all    = $repo->findAll('pages');
$one    = $repo->findOne('pages', $id);
$bySlug = $repo->findBySlug('pages', 'about');