Download the PHP package maize-tech/laravel-helpers without Composer
On this page you can find all versions of the php package maize-tech/laravel-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maize-tech/laravel-helpers
More information about maize-tech/laravel-helpers
Files in maize-tech/laravel-helpers
Package laravel-helpers
Short Description Laravel Helpers
License MIT
Homepage https://github.com/maize-tech/laravel-helpers
Informations about the package laravel-helpers
Laravel Helpers
This repository contains some useful helpers for most applications using Laravel.
Installation
You can install the package via composer:
You can publish the config file with:
This is the content of the published config file:
Usage
To use the package, you can simply call the hlp()
helper function, followed by one of the Available methods methods listed below.
If needed, you could also call the static method directly.
Here's an example using both the helper function and the static method:
Available methods
anonymizeFilename
classUsesTrait
instanceofTypes
isUrl
modelKeyName
morphClassOf
resolveMorphedModel
paginationLimit
pipe
sanitizeArrayOfStrings
sanitizeString
sanitizeUrl
anonymizeFilename
The anonymizeFilename
function returns a randomized name of the given file followed by its extension.
classUsesTrait
The classUsesTrait
function returns whether a class object or name uses the given trait or not.
instanceofTypes
The instanceofTypes
function returns whether a class object is an instance of at least one of the given types or not.
isUrl
The isUrl
function returns whether a string is a valid URL or not.
modelKeyName
The modelKeyName
function returns the key name of a given model object or class name.
morphClassOf
The morphClassOf
function returns the morph class name of a given model object or class name.
resolveMorphedModel
The resolveMorphedModel
function returns the fully qualified model class name of a given morph class name.
You can either pass the singular or plural name of the morph class name.
paginationLimit
The paginationLimit
function returns the amount of items per page.
It is useful when working with queries who need a pagination, and allows to define a default pagination limit and the max amount of items per page.
It will also check whether the request's query string contains a limit
parameter: if true, the given limit overrides the default limit.
pipe
The pipe
function allows you to integrate Laravel pipelines with ease.
The first parameter is the object to be sent through the pipeline, while the second is the list of pipes.
sanitizeArrayOfStrings
The sanitizeArrayOfStrings
function sanitizes an array of strings by removing all HTML tags and whitespace from both ends.
When passing an associative array, it also filters all keys with an empty value.
sanitizeString
The sanitizeString
function sanitizes a string by removing all HTML tags and whitespace from both ends.
sanitizeUrl
The sanitizeUrl
function prepends the specified url with the https
protocol if none is set.
Adding custom helper methods
If needed, you can easily add your own helper methods.
All you have to do is define your custom helper class and implement the HelperMacro
interface:
After that, you can add your method to the macros
attribute from config/helpers.php
:
Alternatively, if you need to define custom helpers at runtime, you can call the macro
static method of the Helper
class:
You can now call your custom helper method with the hlp()
helper method:
Testing
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
- Enrico De Lazzari
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-helpers with dependencies
illuminate/database Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
spatie/laravel-package-tools Version ^1.14.1