sheenazien8 / konstantiq
The missing constant class in laravel
Fund package maintenance!
sheenazien8
Buy Me A Coffee
trakteer.id/sheenazien8/tip
saweria.co/sheenazien
Requires
- php: ^8.1
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
README
This is a simple package that helps you manage your constant values. The root cause of this library is that sometimes you need the status in the view or the API response, but you have more than one status. You can look at the example below.
<?php class SomeClass { // This method returns an array of status strings public function pain(): array { return [ 'Pending', 'Failed', 'Done' ]; } // This method returns an array of status constants from PaymentStatus public function healthy(): array { return PaymentStatus::all()->toArray(); } }
Installation
You can install the package via composer:
composer require sheenazien8/konstantiq
You can publish the config file with:
php artisan vendor:publish --tag="konstantiq-config"
Usage
php artisan make:constant PaymentStatus #it will generate class \App\Constants\PaymentStatus
<?php namespace App\Constants; use Sheenazien8\Konstantiq\ConstanstAbstraction; class PaymentStatus extends ConstanstAbstraction { // You can add the constants that you need const PENDING = 'pending'; const DONE = 'done'; } // Usage example PaymentStatus::PENDING; // will return the 'pending' value PaymentStatus::all(); // will return the all of the constants
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.