Package for creating admin panel in Laravel projects

What, in your opinion, is the most terrible and boring step in creating a site in PHP? In my opinion - this is the creation of the admin panel. All these monotonous forms, tables, a large number of almost identical files, which must not only be created, but subsequently maintained. Therefore, for each framework I use, sooner or later I created a set of classes to facilitate this process.

And so I got to Laravel. I present to you a package that will help you quickly create an admin panel and spend more time on the frontend.

You ask, what in my "bicycle" made me publish it for all to see? For me, this is his several strengths:

In the zero , he helps me in real projects. Perhaps it will help someone else, and this already means that everything was done not in vain.

Firstly , configuration files.

I'm tired of the configs, which are a magically created array, in which there are keys with certain names and text values ​​of these keys. There is no help for you from the IDE with automatic substitution or highlighting of incorrectly specified values, to find in the project code where a specific key from the config is specifically processed and what it does is far from a trivial task. And besides, the package code here is a weak helper for you, the documentation is your only friend.

Therefore, I refused the configs in the form of arrays (php arrays, yaml files, it does not matter) and came to the configs in the form of php code. Here is a small example of the description of the Country model from the demo application for use in the admin panel.

Admin::model('\Country')->title('Countries')->with('contacts')->columns(function ()
{
	Column::string('title', 'Title');
	Column::count('contacts', 'Contacts')->append(Column::filter('country_id')->model('\Contact'));
})->form(function ()
{
	FormItem::text('title', 'Title');
});


I don’t know about you, but it seems to me much more convenient to read than an array with keys, although in fact it contains all the same information.

Several advantages of this approach:

  • Your IDE will know the execution context of this code and will be able to tell you what types of columns or form elements exist and what additional parameters a particular element takes;
  • A typo in the name of the "key" will automatically lead to an error that the config on the array cannot provide;
  • Parsing an array containing so much information is not a pleasant task. Immediately, it simply does not exist, as a result of which the code becomes cleaner.

Secondly , extensibility.

You can register your own column types and form elements that will later be used in your models. Therefore, you are not limited solely to the functionality that I created.

You can also register your own controllers for processing certain menu items - and here you are already unlimited.

Thirdly , the amount of work that needs to be done to create the admin panel.

You will need to create a menu, as well as create a description of each model for which you need to create an admin panel. And it's all.

I created this package for use mainly in small projects that have many loosely coupled models. As a rule, their main goal is to display the data in the front-end in accordance with the design, and what kind of admin panel will be there for the customer is not so important, if only it fulfills the main goal - managing the content of the site.

GitHub sources | project documentation | demo application

Also popular now: