Generate Your resource fields with no pain!

INANI El Houssain
2 min readAug 23, 2018

--

Laravel Nova is such a great tool for us developers to create an admin panel that handles our models easily and quickly. I’ve always hated working on Backoffice because of that repetitive work. I guess everybody thinks that way🤣

Actually, the tool I’ve made helps you to generate the fields array based on the columns related to the model, Actually it does more than that, it assists you in that operation providing you some options, you won’t have to record them anymore(If you ever did).

You can find the repository here Click Me

Once you install it let us check how we can use it.

1 — Select the model

Run the only command you will have to use.

php artisan nova-resource-fields:generate

And type the full path of the Model you want to generate fields for.

2 — Select field and rules

Once you have selected the model a list of columns will be printed, an other list of possible options is provided eventually based on the column type in your database.

After that you may want to add rules to the field for the form validation, you can find here the list of available rules

3 — Add Visibility restriction

And yes, you can customize the fields to be shown in list and not in others pages etc, you can easily manage that with next step

Just type the codes of the methods you want to include, I think everything is clear.

4 — Sortable and generate the code

Now you only have to chose if you want the field to be sortable or not. after that you will be asked to continue the same process for others columns, sure you can stop and the code will be generated. Copy it, past it and don’t forget to include the namespace where the fields are.

Hope it is helpful for you guys! Use it and share!

Happy coding.

--

--