Core utilities for Laravel to extend some functionality and prepare project for other related packages
ptuchik/core-utilities is a Laravel package for core utilities for laravel to extend some functionality and prepare project for other related packages.
It currently has 3 GitHub stars and 19.407 downloads on Packagist (latest version 1.0.42).
Install it with composer require ptuchik/core-utilities.
Discover more Laravel packages by ptuchik
or browse all Laravel packages to compare alternatives.
Last updated
This package includes some useful utilities for Laravel 5.5+ to extend some functionality and prepare project for other related packages
class AbstractTypes - Extend this class and add your constants to use them later easily.class Gender extends AbstractTypes {
const MALE = 1;
const FEMALE = 2;
}
print_r(Gender::MALE); // Output: 1
print_r(Gender::FEMALE); // Output: 2
print_r(Gender::all()); // Output: '1,2'
print_r(Gender::all('json')); // Output: '{"1":"translated.male","2":"translated.female"}'
// You can also pass second parameter false, to not translate the values
print_r(Gender::all('json', false)); // Output: '{"1":"MALE","2":"FEMALE"}'
print_r(Gender::all('array')); // Output: ["MALE" => 1, "FEMALE" => 2]
class AppEngineCron - Just a middleware to filter and allow only requests from Google AppEngine's CRONJust add to routes you need to filter
class ForceSSL - Middleware to convert HTTP reuests to HTTPS if set in configurationEdit protocol parameter in configuration file and add to routes you need to convert
class Handler - Exception to RESTful error messages converterExtend your App/Exceptions/Handler from this class, and you will get all exceptions prettified for RESTful API
class Model - This class extends from native Eloquent Model and adds some useful features like camelCase attributes, translatable attributes and optional and configurable attribute sanitizationExtend all your model's from this one instead of native Illuminate\Database\Eloquent\Model and you will get them all automatically
trait HasParams - You can use this trait in all your models which have params attribute in databaseDO NOT FORGET to cast your params attribute as array before using this trait
trait HasIcon - You can use this trait in all your models which have icon. This will add $model->saveIcon($image); and $model->deleteIcon(); methods.DO NOT FORGET to add icon column to your model's table before using this trait
class Storage - You can use it as a factory for your storageuse Ptuchik\CoreUtilities\Helpers\Storage;
$storage = new Storage(); // Pass true as the only parameter if you need to initialize your public storage
// ... after initialization you can use $storage variable as regular Filesystem Adapter. like:
$storage->get($path);
$storage->put($path);
// ...etc...