bramalho / laravel-utils
Laravel Utils Package
v1.0.2
2019-02-16 10:17 UTC
Requires
- php: >=7.1.3
- laravel/framework: ^5.5
This package is auto-updated.
Last update: 2024-11-16 22:53:18 UTC
README
Laravel Utils is a package that provide several base classes for your project:
- Repository
- Basic Enum
Installation
Install the package
composer require bramalho/laravel-utils
Add the service provider in config/app.php
BRamalho\LaravelUtils\LaravelUtilsServiceProvider::class,
Publish the configs
php artisan vendor:publish --provider 'BRamalho\LaravelUtils\LaravelUtilsServiceProvider'
Usage
Repository
Extend any of your Repository CLasses with Repository
<?php namespace App\Repositories; use App\User; use BRamalho\LaravelUtils\Repository; class UserRepository extends Repository { public function __construct(User $model) { parent::__construct($model); } }
Basic Enum
<?php namespace App; use BRamalho\LaravelUtils\BasicEnum; abstract class StatusEnum extends BasicEnum { const ACTIVE = 1; const INACTIVE = 0; } StatusEnum::getConstants(); //["ACTIVE" => 1, "INACTIVE" => 0] StatusEnum::isValidName('ACTIVE'); //true StatusEnum::isValidName('WAITING'); //false StatusEnum::isValidValue(1); //true StatusEnum::isValidValue(2); //false
License
The Laravel Utils is open-sourced software licensed under the MIT license.