PHP code example of prometa / sleek

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

    

prometa / sleek example snippets


Sleek::assets([
    'vite' => [ /* Your vite bundles go here */ ],
    /* additional dependencies go here */
]);

Sleek::menu([
    [
        'route' => route('index'),
        'label' => __('navbar.index'),
    ],
    [
        /* Enables flexible icon usage via the `icon` attribute:
         * 
         * - Simple Bootstrap icon (e.g., 'people'): 'people' will use the 'bi-people' class on the icon tag.
         * - Explicit Bootstrap icon with 'bi:' prefix (e.g., 'bi:people'): 'bi-people' class on the icon tag.
         * - Blade component with 'component:' prefix (e.g., 'component:my-icon'): will use the component 'my-icon'.
         *   It's also possible to use namespaced components (e.g., 'my-icons::my-icon')
         */
        'icon' => 'people',
        'route' => 'routes('customers'),
        'label' => __('navbar.customers'),
    ],
    [
        'label' => __('navbar.settings'),
        /* Navigation items can be nested. Items have the same structure as top-level items.
         * As of now, only one level of nesting is supported.
         */
        'items' => [
            'route' => route('settings.general'),
            'label' => __('navbar.general'),
        ]
    ],
])

Sleek::menu(fn () => [
    [
        'route' => route('index'),
        'label' => __('navbar.index'),
    ],
])

Sleek::authentication(['login' => '/custom-login', 'logout' => '/custom-logout']);

Sleek::authentication(false);

Sleek::language(['de' => 'Deutsch', 'en' => 'Englisch']);

[
    'name' => '...',
    'address' => '...',
    'contact' => [
        'name' => '...',
        'address' => '...'
    ],
]

User::query()
    ->when(request('sort-by'))
    ->orderBy(
        request('sort-by'),
        requres('sort-direction'),
    )
    ->get();

User::query()
    ->paginate(request('page-size'));

$request->all();
/* [
 *     'sort-by' => 'name',
 *     'sort-direction' => 'asc'
 * ]
 */

User::query()
    // Will apply ->orderBy('name', 'asc')
    ->autoSort()
    ->get()

$request->all();
/* [
 *     'page-size' => '100',
 *     'page' => '1'
 * ]
 */

User::query()
    ->autoPaginate(50) // Default items per page 50
    // Will append ->paginate(100)

/* [
 *     'name' => 'James', 
 *     'age' => 25, 
 *     'role' => 'admin,user' 
 * ]
 */

User::query()
    ->autoFilter([
        'name' => 'like', 
        // ->where('name', 'like', '%James%')
        'age' => 'gte', 
        // `->where('age', '>=', 25)`
        'role' => 'for_each|equals' 
        // ->where('role', 'admin')->where('role', 'user')
    ])
    ->get()

use Prometa\Sleek\Facades\Sleek;

Sleek::raise('Your message goes here', 'danger');

Sleek::alert([
    'position' => 'top-right'
]);
bash
php artisan sleek:setup
blade
{{-- contacts/form.blade.php --}}
@props(['name' => null])

<x-sleek::form-group :name="$name">
    <x-sleek::form-field name="name" />
    <x-sleek::form-field name="address" />
</x-sleek::form-group>
blade
{{-- Will set method="POST" --}}
<x-sleek::entity-form />

{{-- Will set method="PUT" --}}
<x-sleek::entity-form :model="$user" />

{{-- Explicitly setting the method overrides automatic guessing, so method="PATCH" --}}
<x-sleek::entity-form :model="$user" method="PATCH" />