PHP code example of ginkelsoft / buildora

1. Go to this page and download the library: Download ginkelsoft/buildora 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/ */

    

ginkelsoft / buildora example snippets


TextField::make('name')->sortable()
EmailField::make('email')->readonly()
PasswordField::make('password')->hideFromIndex()
NumberField::make('price')->step(0.01)
CurrencyField::make('amount', '€')
DateTimeField::make('created_at')->readonly()
BelongsToField::make('company_id')->relation('company')

class TotalUsersWidget extends Widget
{
    public function render(): string
    {
        $count = User::count();

        return view('widgets.total-users', compact('count'))->render();
    }
}

public function defineWidgets(): array
{
    return [
        TotalUsersWidget::make()->columnSpan(6),
    ];
}

public function definePanels(): array
{
    return [
        Panel::relation('orders', OrderBuildora::class)->label('Recent Orders'),
        Panel::relation('invoices', InvoiceBuildora::class),
    ];
}

public function defineRowActions(): array
{
    return [
        RowAction::make('Edit', 'fas fa-edit', 'route', 'buildora.edit')
            ->params(['resource' => 'user', 'id' => '{id}'])
            ->method('GET'),

        RowAction::make('Delete', 'fas fa-trash', 'route', 'buildora.destroy')
            ->params(['resource' => 'user', 'id' => '{id}'])
            ->method('DELETE')
            ->confirm('Are you sure you want to delete this record?'),
    ];
}

public function defineBulkActions(): array
{
    return [
        BulkAction::make('Delete Selected', 'buildora.bulk.delete')
            ->method('DELETE')
            ->confirm('Are you sure you want to delete the selected records?'),

        BulkAction::make('Export Selected', 'buildora.bulk.export')
            ->method('POST'),
    ];
}

RowAction::make('Delete', 'fas fa-trash', 'route', 'buildora.destroy')
    ->permission('user.delete');

public function searchResultConfig(): array
{
    return [
        'label' => fn($record) => $record->name,
        'columns' => ['name', 'email', 'created_at'],
    ];
}

'route_prefix' => 'buildora',  // Base URL path
'middleware' => ['web', 'buildora.auth', 'buildora.ensure-user-resource'],

'models_namespace' => 'App\\Models\\',

'datatable' => [
    'pagination' => [10, 25, 50, 100, 250],
    'default_per_page' => 25,
],

'files' => [
    'default_disk' => 'public',
    'default_path' => 'uploads',
    'max_upload_size_kb' => 2048,
    'previewable' => ['jpg', 'jpeg', 'png', 'pdf'],
],

'dashboards' => [
    'enabled' => true,
    'label' => 'Dashboards',
    'icon' => 'fa fa-gauge',
    'children' => [
        'main' => [
            'label' => 'Main',
            'route' => 'buildora.dashboard',
            'params' => ['name' => 'main'],
            'permission' => 'dashboard.view',
            'widgets' => [],
        ],
    ],
],

'navigation' => [
    // Link to a Buildora resource
    [
        'label' => 'Users',
        'icon' => 'fas fa-user',
        'route' => 'buildora.index',
        'params' => ['resource' => 'user'],
    ],

    // Link to an external URL
    [
        'label' => 'Documentation',
        'icon' => 'fas fa-book',
        'url' => 'https://docs.example.com',
    ],

    // Link to a custom Laravel route
    [
        'label' => 'Back to site',
        'icon' => 'fas fa-home',
        'url' => '/',
    ],

    // Nested navigation with children
    [
        'label' => 'Settings',
        'icon' => 'fas fa-cog',
        'children' => [
            [
                'label' => 'Users',
                'icon' => 'fas fa-user',
                'route' => 'buildora.index',
                'params' => ['resource' => 'user'],
            ],
            [
                'label' => 'Permissions',
                'icon' => 'fas fa-lock',
                'route' => 'buildora.index',
                'params' => ['resource' => 'permission'],
            ],
        ],
    ],

    '
bash
php artisan vendor:publish --tag=buildora-config
bash
php artisan buildora:install
bash
php artisan buildora:resource User
bash
php artisan buildora:widget StatsWidget
bash
php artisan vendor:publish --tag=buildora-theme