πUsage
This page explains the functions structure and examples.
use Helpify\Helpers;
$url = 'https://www.example.com';
$shortenedURL = Helpers::short_url($url);
//---------------
$shortenedURL = short_url($url); // https://is.gd/dsUwVY" Parameters
$url(string): The URL to shorten.
Return Value
(string): The shortened URL.
Checks if a given IP address is valid.
use Helpify\Helpers;
$ip = '192.168.1.1';
$isIPAddressValid = checkValidIpAddress($ip);
// OR
$isIPAddressValid = Helpers::checkValidIpAddress($ip);Parameters
$ip(string): The IP address to check.
Return Value
(bool):
trueif the IP address is valid,falseotherwise.
Gets the client's IP address from various possible sources, such as HTTP headers and server variables.
Return Value
(string): The client's IP address.
Gets the client's browser based on the User-Agent header.
Return Value
(string): The client's browser.
Generates an HTML tag with attributes
Parameters
$tag(string): The tag name.$attributes(array, optional): The attributes of the tag.$content(string, optional): The content of the tag.
Return Value
(string): The generated HTML tag.
Gets the client's operating system based on the User-Agent header.
Return Value
(string): The client's operating system.
Gets the type of device used by the client based on the User-Agent header.
Return Value
(string): The client's device.
Gets the client's country based on their IP address.
Return Value
(string): The client's country.
Get the CSS class for the active route.
Parameters
$routes(array): The routes to check for activity.$output(string, optional): The output class to return if a match is found (default: "active").
Return Value
(string|null): The output class if the current route matches any of the provided routes, otherwise
null.
Formats a date in the specified format.
Parameters
$format(string): The date format (e.g., 'Y-m-d H:i:s').$date(\DateTimeInterface): The DateTime object to format.
Return Value
(string): The formatted date.
Truncates a string to a specified length and appends '...' if the string is longer than the specified length.
Parameters
$string(string): The string to truncate.$length(int): The desired length.
Return Value
(string): The truncated string.
Generates a URL-friendly slug from a given string by replacing non-alphanumeric characters with hyphens.
Parameters
$string(string): The string to convert to a slug.
Return Value
(string): The generated slug.
Generates a random string of a specified length.
Parameters
$length(int, optional): The length of the random string (default: 10).
Return Value
(string): The generated random string.
Flattens a multi-dimensional array into a single level.
Parameters
$array(array): The array to flatten.
Return Value
(array): The flattened array.
Generates an HTML link with the target attribute set for external link
Parameters
$url(string): The URL of the link.$text(string): The anchor text of the link.
Return Value
(string): The HTML link.
Shuffles an array using a seeded random number generator for reproducibility.
Parameters
$array(array): The array to shuffle.
Return Value
(array): The shuffled array.
Generates a slug for a Laravel model instance using the specified field.
Parameters
$model(\Illuminate\Database\Eloquent\Model): The Eloquent model instance.$field(string, optional): The field to use for generating the slug (default: 'name').
Return Value
(string): The generated slug.
Add or update a key-value pair in the .env file.
Parameters
$key(string): The key to add or update.$value(string): The value to set for the key.
Return Value
(void)
Add a new line to the .env file.
Parameters
$key(string): The key to add or update.$value(string): The value to set for the key.
Return Value
(void)
Converts a string to camel case.
Parameters
$string(string): The string to convert.
Return Value
(string): The camel case version of the string.
Last updated
Was this helpful?