xt/laravel-inertia-element-ui-crud

Generate CRUD files for element ui + inertia js + Vue3

v1.0.6 2024-10-09 07:19 UTC

This package is auto-updated.

Last update: 2024-12-09 09:31:24 UTC


README

Latest Version on Packagist Total Downloads

Generate CRUD for Element-UI (Vue 3) and Inertia Js.

This package will generate files to perform CRUD, based on the database table schema. It will generate all the fields in list, create and update form pages.

Vue Plugin

Features

  • Generate list, create and update view pages
  • Generate controller which perform insert, update and delete
  • Generate form for all the fillable fields defined in model file
  • Server side validation (required and maximum length)

Installation

You can install the package via composer:

composer require xt/laravel-inertia-element-ui-crud

Install npm package:

npm install laravel-inertia-element-ui-crud-vue3 --save

Add code

add following function to the app/Http/Controllers/Controller.php

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;
}

Usage

Add following code to the boot method of the app/Providers/AppServiceProvider.php

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) [];
    },
]);

Command to generate CRUD

php artisan crud:generator <ControllerName> <ModelName>

Prepare model before generate crud

make sure controller name without including controller for example User which generates UserController

Example:

#This will generator view file for Jetstream

php artisan crud:generator User User

or

#This will generator view file for breeze

php artisan crud:generator User User --template=breeze

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email hiren.reshamwala@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.