Package Data | |
---|---|
Maintainer Username: | mohsentm |
Maintainer Contact: | Hosseini.m1370@gmail.com (Mohsen Hosseini) |
Package Create Date: | 2018-11-12 |
Package Last Update: | 2024-04-17 |
Language: | PHP |
License: | Apache-2.0 |
Last Refreshed: | 2024-12-23 03:16:05 |
Package Statistics | |
---|---|
Total Downloads: | 3,099 |
Monthly Downloads: | 5 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 2 |
laravel-db-enum is a trait for laravel models. use this trait on modules for getting the table fileds enum values.
tags: laravel, lumen, eloquent, enum field
Pull this package via Composer.
{
"require": {
"mohsentm/laravel-db-enum": "^1.*"
}
}
or run in terminal:
composer require mohsentm/laravel-db-enum
use this trait use Mohsentm\EnumValue;
your the model.
namespace App;
use Illuminate\Database\Eloquent\Model;
use Mohsentm\EnumValue;
class TestModal extends Model
{
protected $table = "test";
//Get enum value trait
use EnumValue;
}
then use getEnumValues()
function to get enum values
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\TestModal;
class TestController extends Controller
{
public function index(){
//return the array of table enum value list
return TestModal::getEnumValues();
}
}
result
{"user_status":["enable","disable"]}
To have best performance this package cache the result.
Would you like to help with this project? Great! You don't have to be a developer, either. If you've found a bug or have an idea for an improvement, please open an issue and tell us about it.
If you are a developer wanting contribute an enhancement, bug fix or other patch to this project, please fork this repository and submit a pull request detailing your changes. We review all PRs! This open source project is released under the Apache 2.0 license which means if you would like to use this project's code in your own project you are free to do so. Speaking of, if you have used our code in a cool new project we would like to hear about it! Please send us an email.
Please refer to the LICENSE file that came with this project.