Download the PHP package repat/laravel-helper without Composer
On this page you can find all versions of the php package repat/laravel-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-helper
laravel-helper
laravel-helper is a package full of helper functions I found useful when developing applications with Laravel. All functions are wrapped with a functions_exists()
in case of conflicts.
Also have a look at
- https://laravel.com/docs/10.x/helpers
- http://calebporzio.com/11-awesome-laravel-helper-functions (abandoned?)
- https://packagist.org/packages/illuminated/helper-functions
- https://packagist.org/packages/laravel/helper-functions
Ideas what should go in here? Write a pull request or email!
Installation
$ composer require repat/laravel-helper
Documentation
⚠️ The majority of helper functions are now in repat/php-helper which this package is based on. You can find the documentation at https://github.com/repat/php-helper
Database
mysql_headers($table, $assoc = false)
Returns an array of MySQL headers/columns or empty array in case of an error. If the second parameter is set true
(default is false
) it returns an associative array.
table_headers($model)
Returns the database table headers, similar to mysql_headers()
, but based on an object of a Eloquent Model.
print_db_session($table = 'sessions')
print_r()
the session of current user.
get_free_slug($toSlug, $field, $fqcn, $id, $pk)
Returns a unique slug for an Eloquent Model given the following parameters:
$toSlug
: suggestion for the slug$field
: name of the database field, usuallyslug
$fqcn
: Fully qualified class name of Eloquent Model$id
: id to exclude (e.g. it's own on update)$pk
: primary key of the database table, defaults toid
Will append a number if $toSlug
is already taken.
insert_bindings($query)
Inserts values into ?
from the ->toSql()
string.
Object
morph_map()
Returns the morphMap from AppServiceProvider
set with Relation::morphMap()
.
morph_map_key($fqcn)
Reverse lookup for a class in the morphMap of the AppServiceProvider
set with Relation::morphMap()
.
cache_get_or_add($key, $callable)
Returns Cache for given key or adds the return value from the callable to the cache and then returns it.
dispatch_tinker($job)
Dispatches jobs from the tinker REPL.
Networking
route_path($path)
Get the path to the Laravel routes folder, similar to app_path()
, see Helpers Documentation. It will append $path
but it's not mandatory.
named_routes($path, $verb)
Returns array of all named routes in a routes file or null
on error. It's possible to pass an HTTP verb/method defined in HTTP_VERBS_LARAVEL
(see below).
current_route_name()
If the current route has a name, otherwise return null
.
all_routes()
Returns an array of all routes like so:
route_exists($namedRoute)
Checks if the given route is a named route in any routes file.
Optional Packages
Optional packages suggested by this are required for these functions to work.
translated_attributes($fqcn)
Uses astrotomic/laravel-translatable and Reflection to get the translatedAttributes
attribute of a Model.
$ composer require astrotomic/laravel-translatable
HTML
extract_inline_img($text, $storagePath, $srcPath, $optimize)
Extracts an inline image from a text, saves it on the harddrive and puts in the filename with the src attribute. Can use the spatie/laravel-image-optimizer to optimize images after upload but it's disabled by default.
$ composer require spatie/laravel-image-optimizer
Constants
HTTP_VERBS_LARAVEL
: [all, get, head, post, delete, options, put, patch]REGEX_IMG_BASE64_SRC
: Regular Expression used to find a base64 encoded image in HTML textREGEX_IMG_BASE64_REPLACE
: Regular Expression used to replace a base64 encoded image in HTML textMULTIPLE_TRANS
: 2
Contributors
License
- MIT, see LICENSE
Version
- Version 0.6
Contact
repat
- Homepage: https://repat.de
- e-mail: [email protected]
- Twitter: @repat123
All versions of laravel-helper with dependencies
php Version >=7.2
repat/php-helper Version ^0.1.15