Skip to content

Usage ​

Create your first CRUD ​

Go to /generators/create if yo're using Full Version

/simple-generators/create for Simple Version

Below is table about supported input type & validation when you are using some column type.

Column TypeInput TypeValidation
stringtext, textarea, email, telephone, password, url, search, file, hiddenrequired, string, min, max
booleanradio, select, datalistrequired, boolean
chartext, color, week, email, telephone, password, url, search, file, hiddenrequired, string, min, max
datedate, monthrequired, date
timetimerequired, date
year, foreignIdselect, datalistrequired, numeric
dateTimedatetime-localrequired, date
float, decimal, doublenumber, range, hiddenrequired, numeric
enumselect, radio, datalistrequired, in
integer, tinyInteger, mediumInteger, bigIntegernumber, range, hiddenrequired, numeric
text, tinyText, mediumText, longTexttext, textarea, email, telephone, password, url, search, file, hiddenrequired, string, min, max

INFO

required validation will change to nullable if you uncheck required switch in the form, if any input type password will automatically added confirmed validation, min:1|max:100 for supported length column and email|unique for email input type.

INFO

404 Laravel

After creating the new module, the 404 error may show, if this occurs, simply refresh the browser.

Create a Relation ​

Create Relation

Currently, only One To Many (Inverse) / Belongs To relationships are supported. There are specific rules you must follow to create a relation:

  • Field name:
    • Must be the table name but in singular + _id, eg: if we have a users table then it must be a user_id.
  • Column Type:
    • Change to foreignId.
    • For constrain or related model name, you can fill with Model name (automatically change to plural).
    • Action on update & delete:
      • On update: nothing, cascade, restrict
      • On delete: nothing, cascade, restrict, null

WARNING

Ensure that the related table and model already exist. If they don't, attempting to display or use them in a <select> or <datalist> will result in an error. By default, the id field is chosen to appear in the dropdown or autocomplete list, while the selected field typically corresponds to the second column in the relevant table.

Create an Upload File ​

Upload File

Set the column type to string, the input type to file, and select the file type (currently only supporting images). Fill in the max size, and the default value is optional (must be a valid link).

We use Intervention Image for manipulating uploaded images. All settings for images are available in config/generator.php.

Default image configuration:

php
"image" => [
    /**
    * Path for store the image.
    *
    * Available options:
    * 1. public
    * 2. storage
    * 3. s3
    */
    "disk" => "storage",  

    /**
    * Will used if image is nullable and default value is null.
    */
    "default" => "https://via.placeholder.com/350?text=No+Image+available",  

    /**
    * Crop the uploaded image using intervention image.
    */
    "crop" => true,  

    /**
    * When set to true the uploaded image aspect ratio will still original.
    */
    "aspect_ratio" => true, 

    /**
    * Crop image size.
    */
    "width" => 500, 
    "height" => 500, 
],

INFO

If you are using storage for store the image, make sure you run

sh
php artisan storage:link

Or if you are using s3 to store the image, make sure you read the documentation

Create a Sidebar Menu ​

Create sidebar menu

INFO

This feature only available in full version.

You can easily create a dynamic sidebar menu with just a few inputs. All sidebar menu configurations are placed in config/generator.php.

What if you don't need a dynamic sidebar menu and prefer to create your menu in blade? No problem, we provide support for that too. Click here to learn how to do it.

Role & Permissions ​

When using the full version, creating a new module will automatically generate specific permissions and assign them to the admin role. All permissions are managed in config/permission.php.

Here an example:

php
[
    'group' => 'products',  
    'access' => [  
        'product view',  
        'product create',  
        'product edit',  
        'product delete'
    ] 
],

Creating API CRUD ​

Before you use this feature, make sure you have installed and read the latest documentation of Laravel 11 regarding APIs.

  1. Execute the following command
sh
php artisan install:api
  1. Check if the routes/api.php file is exists
  2. Go to bootstrap/app.php and remove or add the following code
php
->withRouting(
    api: __DIR__ . '/../routes/api.php', 
    web: __DIR__ . '/../routes/web.php',
    commands: __DIR__ . '/../routes/console.php',
    health: '/up',
)
  1. If you want an authentication module, such as login and register, please execute the following command
sh
php artisan generator:publish-api

This command will generate some code in app/Http/Controllers/Api/AuthController, app/Http/Requests/Auth, and routes/api.php

For the full version, navigate to /generators-api/create. For the simple version, go to /simple-generators/create. Then, follow the same steps you used to create CRUD operations above.

INFO

If you are using the API Generator in the full version, sidebar menu creation is not available.