PHP code example of xt / laravel-inertia-element-ui-crud

1. Go to this page and download the library: Download xt/laravel-inertia-element-ui-crud 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/ */

    

xt / laravel-inertia-element-ui-crud example snippets


function filterOrderParameters(){
    $sort_order = \request('order', 'd');
    if ($sort_order == ''){
        $sort_order = 'd';
    }
    if ($sort_order == 'a'){
        $sort_order = 'asc';
    } else {
        $sort_order = 'desc';
    }
    return $sort_order;
}

Inertia::share('flash', function () {
    return [
        'message' => Session::get('message'),
    ];
});

Inertia::share([
    'success' => function () {
        return Session::get('success')
            ? Session::get('success')
            : '';
    },
]);

Inertia::share([
    'error' => function () {
        return Session::get('error')
            ? Session::get('error')
            : '';
    },
]);

Inertia::share([
    'errors' => function () {
        return Session::get('errors')
            ? Session::get('errors')->getBag('default')->getMessages()
            : (object) [];
    },
]);
bash
php artisan crud:generator <ControllerName> <ModelName>