You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-8Lines changed: 49 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,22 +3,17 @@ KV Pair System For Laravel 5.4
3
3
4
4
## Introduction
5
5
6
-
Key-Value pair is being used in most of the cases where only developer will maintain & change the list. Developer usually tends to keep these key-value pair config file.
6
+
Key-Value pair is being used in most of the cases where only developer will maintain and change the list. Developer usually tends to keep these key-value pair config file.
7
7
8
-
While this works just fine in small applications, it becomes very difficult to manage & maintain when the list grows.Unfortunately all application starts small, but grows big very quickly.
8
+
While this works just fine in small applications, it becomes very difficult to manage and maintain when the list grows.Unfortunately all application starts small, but grows big very quickly.
9
9
10
10
To address this problem, I have developed a KV Pair system for laravel framework which stores the KV Pair in the database.
11
11
12
-
#### Benefits, Benefits & Benefits
12
+
#### Benefits, Benefits and Benefits
13
13
- All your KV Pair are inside on table. Hence you can use them in your SQL joins
14
14
- You can give description for every KV Pair
15
15
- You can put KV pairs in a group (aka Group them)
16
16
- Get the KV pairs ready to bind with select html control
17
-
For Example : <select>
18
-
<option>Select</option>
19
-
<option>In Progress</option>
20
-
<option>Completed</option>
21
-
</select>
22
17
- Multiple Language Support for "select" string
23
18
24
19
@@ -34,16 +29,29 @@ After updating composer, add the ServiceProvider to the providers array in confi
34
29
35
30
### Laravel 5.x:
36
31
32
+
#### Add Service Provider
33
+
37
34
```php
38
35
sachingk\kvpair\KVPairServiceProvider::class,
39
36
```
40
37
38
+
#### Add Facade
39
+
41
40
If you want to use the facade , add this to your facades in app.php:
42
41
43
42
```php
44
43
"KVPair"=> sachingk\kvpair\Facade\kvpair::class,
45
44
```
46
45
46
+
#### Make Migration
47
+
48
+
Now you need to run artisan migrate command via command line. If you wish to add more columns to the table before migration then run the following command in command line.
49
+
50
+
```php
51
+
php artisan vendor:publish --tag=migrations
52
+
```
53
+
54
+
Now the migration file get copied to /database/migrations folder. Add any extra columns you need and then run the migrate artisan command.
47
55
48
56
## Usage
49
57
@@ -347,5 +355,38 @@ KVPair::countAllKVPair()
347
355
This function will return the integer value.
348
356
349
357
## Configuration
358
+
This package has 2 configurations which developer can set based on their choice.
359
+
360
+
- alwaysGetForDropdown
361
+
- selectKey
362
+
363
+
##### alwaysGetForDropdown
364
+
If this is set to TRUE all the get functions (except getKVPairByKey) will give the output ready to
365
+
bind with select html control by default. The $forDropDown parameter passed will be ignored
366
+
367
+
##### selectKey
368
+
Value assigned to this will used as a key for select when rendering the get function for dropdown.
369
+
370
+
### How to configure
371
+
To set your configurations , you have to publish the config file using artisan command.
372
+
373
+
```php
374
+
php artisan vendor:publish --tag=config
375
+
```
376
+
```
377
+
378
+
Now the configuration file get copied to /config folder.You can set your preference here.
379
+
380
+
## Multilingual
381
+
382
+
This package support multiple language for "select" during the output for dropdown.The translations are take from the language files based on the setting of locale in /Config/app.php.
383
+
384
+
To start with you can run following publish command to get the default language files of this package.
385
+
386
+
```php
387
+
php artisan vendor:publish --tag=lang
388
+
```
350
389
390
+
Now the language files get copied to /resources/lang folder. You can add more languages from here by creating individual folder for each language and adding kvpair_lang.php under them.
351
391
392
+
For now this package creates language file for english and kannada (indian language)
0 commit comments