leandro-grg / list-maker
A template & db based list generator
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
pkg:composer/leandro-grg/list-maker
This package is auto-updated.
Last update: 2025-12-19 13:20:41 UTC
README
Installation
Require the package with composer
composer require leandro-grg/list-maker
Publish the vendor assets
php artisan vendor:publish --provider='LeandroGRG\ListMaker\Providers\ListMakerServiceProvider'
Add the provider to your application providers
return [ //... 'providers' => [ //... LeandroGRG\ListMaker\Providers\ListMakerServiceProvider::class ] //... ];
Run the package migrations
php artisan migrate
(optional) Alias
You can alias the class by adding the next code snippet to your config/app.php
return [ //... 'aliases' => [ //... 'ListMaker' => LeandroGRG\ListMaker\ListGen::class //... ] //... ];
Usage
To use a list generator, you only need to write this in your view:
{{ ListMaker::make('list-name') }}
Also, you can use the package's custom blade directive:
@list('list-name')
If you won't to use it on a .blade.php file, you can use plain php
<?php LeandroGRG\ListMaker\ListGen::make('list-name') ?>
Creating lists
In order to create lists, just execute the command php artisan list:create-list,
and follow the steps in the interactive cli tool.
This will create an entry in the lists table, and the required folders:
app/Helpers/ListTemplates directory.
Creating items
Run the command php artisan list:create-list-item. The command will prompt you for
the the main list to add the new item. Once you select the list, it will prompt you
for all the properties required for creating the item:
- Type
stringrequired: The item type (itemordivider) - Route
stringnullable: The item route. - Icon
stringnullable: The item icon - Display
stringrequired: The item display text - Order
integerrequired: The order of the item
Templates
All the templates are located in the app/Helpers/ListTemplates directory.
For each list, a directory is created in app/Helpers/ListTemplates/{StudlyCaseListName}.
Lists
Inside the app/Helpers/ListTemplates/{StudlyCaseListName} directory, you will
find two relevant files for the lists:
-
Parser It's a generated class called
{StudlyCaseListName}Parser.phpwith only one method, theparsemethod. It receives the$list (Illuminate\Database\Eloquent\Model)parameter, useful for replacing the strings in the template. Theparsemethod returns an array to be used in thestrtrphp function. -
Template Inside the folder, you can find a file called
ListTemplate.html. That's the list template, you can modify it as you like.
List items
Basically, it works like the list parser, with a little difference:
- Parser
In this case, the parser will have a method for each type of item, following the
pattern
parse{Type}Type. For example, this will be the method for a divider type item:
static function parseDividerType ($item) { return []; }
- Template
And you can find the template for each type of item, in the list folder,
following the next name pattern
{ItemType}Template.html.
Adding custom item types
We're working on this. At the moment, you can use the item and divider item types.