delatbabel / keylists by delatbabel

Laravel key/value lists package.
742
1
4
Package Data
Maintainer Username: delatbabel
Maintainer Contact: del@babel.com.au (Del)
Package Create Date: 2015-12-14
Package Last Update: 2017-06-20
Language: PHP
License: MIT
Last Refreshed: 2024-12-22 03:15:45
Package Statistics
Total Downloads: 742
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 4
Total Forks: 1
Total Open Issues: 0

keylists

Yeah yeah, you know the drill. Your application needs to have all of these key/value tables. A list of states of the USA. A list of currencies. A table for timezones. A table for staff rotation types. A table for the names of the seven dwarfs (NAME THEM! NOW! QUICK!) (*). A key/value list for each of the 101 dropdowns that you have on the far-too-many forms on your site.

Keylists is a set of database tables and model classes to handle key/value lists in an application in a standard way

So you can now store all of these key/value lists into a single set of tables and cache the whole lot and never have to panic about where to store these things ever again.

Installation

Add these lines to your composer.json file:

    "require": {
        "delatbabel/keylists": "~1.0"
    },

Once that is done, run the composer update command:

    composer update

Alternatively just run this:

    composer require delatbabel/keylists

Register Service Provider

After composer update completes, add this line to your config/app.php file in the 'providers' array:

    Delatbabel\Keylists\KeylistsServiceProvider::class,

Incorporate and Run the Migrations

Finally, incorporate and run the migration scripts to create the database tables as follows:

php artisan vendor:publish --tag=migrations --force
php artisan migrate

Sample Data

To load some of the sample data, try adding this line to the $commands array in your app/Console/Kernel.php file:

    \Delatbabel\Keylists\Console\Commands\LoadISO3166Countries::class

Then run this command:

    php artisan keylists:loadiso3166countries

This should create entries in the keylists / keyvalues table for the ISO 3166 country codes and names.

Example

I'll get to that. Quit bugging me, K? Just go read the code.

Notes

(*) Happy, Dumpy, Sleepy, Gropey ... umm, hang on, was Gropey one of them?? ... Flopsy, Mopsy and Cottontail.