ptuchik / core-utilities
Core utilities for Laravel to extend some functionality and prepare project for other related packages
Installs: 18 070
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 4
Open Issues: 0
Requires
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0
- intervention/image: *
- spatie/laravel-translatable: *
- dev-master
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-develop
This package is auto-updated.
Last update: 2024-12-05 10:27:53 UTC
README
This package includes some useful utilities for Laravel 5.5+ to extend some functionality and prepare project for other related packages
Currently included:
class AbstractTypes
- Extend this class and add your constants to use them later easily.
Usage
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 CRON
Usage
Just add to routes you need to filter
class ForceSSL
- Middleware to convert HTTP reuests to HTTPS if set in configuration
Usage
Edit protocol
parameter in configuration file and add to routes you need to convert
class Handler
- Exception to RESTful error messages converter
Usage
Extend 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 sanitization
Usage
Extend 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 haveparams
attribute in database
DO 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 storage
Usage
use 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...