PHPackages                             rishadblack/larahelpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rishadblack/larahelpers

ActiveLibrary

rishadblack/larahelpers
=======================

A collection of useful Laravel helper functions

1.0.4(8mo ago)172MITPHPPHP ^7.2.0|^8.0

Since Oct 4Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/rishadblack/larahelpers)[ Packagist](https://packagist.org/packages/rishadblack/larahelpers)[ RSS](/packages/rishadblack-larahelpers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

LaraHelpers
===========

[](#larahelpers)

**LaraHelpers** is a collection of useful helper functions for Laravel applications, designed to enhance productivity and streamline common tasks.

Installation
------------

[](#installation)

You can install the package via Composer. Run the following command in your Laravel project directory:

```
composer require rishadblack/larahelpers
```

Function Documentation
======================

[](#function-documentation)

This repository contains a collection of utility functions for various tasks. Below is a list of all functions along with a brief description of their purpose.

Function List
=============

[](#function-list)

`generateRandomFloat`
---------------------

[](#generaterandomfloat)

Generates a random floating-point number within a specified range.

**Parameters:**

- `$min` *(float)*: The minimum value of the range (inclusive).
- `$max` *(float)*: The maximum value of the range (inclusive).
- `$decimals` *(int)*: The number of decimal places (default is `2`).

**Returns:** A random float number between `$min` and `$max`.

**Example:**

```
$randomNumber = generateRandomFloat(1.0, 10.0); // e.g., 5.23
```

### `matchRouteParameter`

[](#matchrouteparameter)

Matches the route parameter with the provided data.

**Parameters:**

- `$Data` *(array)*: An array of data to match against.

**Returns:** `true` if the route parameter matches; `otherwise`, `false`.

**Example:**

```
$result = matchRouteParameter(['id' => 123]); // true or false based on the current request
```

### `switchColLang`

[](#switchcollang)

Switches the column name based on the application's locale.

**Parameters:**

- `$enCol` *(string)*: The English column name.
- `$bnCol` *(string)*: The Bangla column name.

**Returns:** The column name based on the current locale.

**Example:**

```
$columnName = switchColLang('name', 'নাম'); // 'name' or 'নাম' based on locale
```

### `perPageRows`

[](#perpagerows)

Returns an array of rows per page options.

**Parameters:**

- `$Data` *(array)*: An array of data options.

**Returns:** An array of row options or a default `array [10, 25, 50, 100, 250]`.

**Example:**

```
$options = perPageRows(); // [10, 25, 50, 100, 250]
```

### `addAllField`

[](#addallfield)

Adds an "All" option to the provided data.

**Parameters:**

- `$Data` *(Collection|array)*: A collection or array of data to which "All" is added.

**Returns:** An array with "`All`" prepended to the original data.

**Example:**

```
$fields = addAllField($data); // [null => 'All', ...]
```

### `currencySymbol`

[](#currencysymbol)

Returns the currency symbol used in the application.

**Returns:** A string representing the currency symbol.

**Example:**

```
$symbol = currencySymbol(); // '৳'
```

### `numberEnToBn`

[](#numberentobn)

Converts English numerals to Bangla numerals.

**Parameters:**

- `$number` *(string)*: The number in English numerals.

**Returns:** A `string` with Bangla numerals.

**Example:**

```
$banglaNumber = numberEnToBn('123'); // '১২৩'
```

### `asset_storage`

[](#asset_storage)

Generates the storage asset URL.

**Parameters:**

- `$path` *(string)*: The path to the asset.

**Returns:** A URL `string` for the asset.

**Example:**

```
$url = asset_storage('uploads/file.jpg'); // URL for the asset
```

### `asset_favicon`

[](#asset_favicon)

Generates the favicon asset URL.

**Parameters:**

- `$path` *(string|null)*: The path to the favicon (defaults to config('app.logo')).

**Returns:** A URL string for the favicon asset.

**Example:**

```
$faviconUrl = asset_favicon(); // URL for the favicon
```

### `asset_logo`

[](#asset_logo)

Generates the logo asset URL.

**Parameters:**

- `$path` *(string|null)*: The path to the logo (defaults to config('app.logo')).

**Returns:** A URL string for the logo asset.

**Example:**

```
$logoUrl = asset_logo(); // URL for the logo
```

### `asset_powered_logo`

[](#asset_powered_logo)

Generates the powered logo asset URL.

**Parameters:**

- `$path` *(string|null)*: The path to the powered logo (defaults to config('app.logo\_powered')).

**Returns:** A URL string for the powered logo asset.

**Example:**

```
$poweredLogoUrl = asset_powered_logo(); // URL for the powered logo
```

### `asset_dark_logo`

[](#asset_dark_logo)

Generates the dark logo asset URL.

**Parameters:**

- `$path` *(string|null)*: The path to the dark logo (defaults to config('app.dark\_logo')).

**Returns:** A URL string for the dark logo asset.

**Example:**

```
$darkLogoUrl = asset_dark_logo(); // URL for the dark logo
```

### `asset_profile_picture`

[](#asset_profile_picture)

Generates the default profile picture asset URL.

**Returns:** A URL `string` for the profile picture asset.

**Example:**

```
$profilePicUrl = asset_profile_picture(); // URL for the profile picture
```

### `numberFormatConverted`

[](#numberformatconverted)

Formats a number with optional currency sign and decimal places.

**Parameters:**

- `$value` *(float|string)*: The number to format.
- `$sign` *(string|bool)*: Optional currency sign (default is false).
- `$decimal` *(int)*: Number of decimal places (default is 2).
- `$thousend` *(string)*: Optional thousand separator.

**Returns:** A formatted `string`.

**Example:**

```
$formatted = numberFormatConverted(12345.678, true); // '$12,345.68' or '৳12,345.68'
```

### `percentFormat`

[](#percentformat)

Formats a number as a percentage.

**Parameters:**

- `$value` *(float|string)*: The number to format.
- `$decimal` *(int)*: Number of decimal places (default is 2).
- `$percentSign` *(string)*: The percent sign (default is %).

**Returns:** A formatted percentage `string`.

**Example:**

```
$percentage = percentFormat(0.256); // '25.60%'
```

### `pointFormat`

[](#pointformat)

Formats a number for display with optional currency sign.

**Parameters:**

- `$value` *(float|string)*: The number to format.
- `$sign` *(string|bool)*: Optional currency sign (default is false).
- `$decimal` *(int)*: Number of decimal places (default is 2).
- `$thousend` *(string)*: Optional thousand separator.

**Returns:** A formatted `string`.

**Example:**

```
$formattedPoint = pointFormat(1234.567, true); // '৳1,234.57'
```

### `unitFormat`

[](#unitformat)

Formats a number with a unit identifier.

**Parameters:**

- `$value` *(float|string)*: The number to format.
- `$unitId` *(string|bool)*: Optional unit identifier (default is false).
- `$decimal` *(int)*: Number of decimal places (default is 0).

**Returns:** A formatted `string` with unit.

**Example:**

```
$formattedUnit = unitFormat(5000, 'kg'); // '5,000kg'
```

### `numberFormat`

[](#numberformat)

Formats a number for display with optional currency sign.

**Parameters:**

- `$value` *(float|string)*: The number to format.
- `$sign` *(string|bool)*: Optional currency sign (default is false).
- `$decimal` *(int)*: Number of decimal places (default is 2).
- `$thousend` *(string)*: Optional thousand separator.

**Returns:** A formatted `string`.

**Example:**

```
$formattedNumber = numberFormat(1000); // '1,000.00'
```

### `numberFormatOrPercent`

[](#numberformatorpercent)

Formats a number or returns a percentage.

**Parameters:**

- `$value` *(float|string)*: The value to format.
- `$sign` *(bool)*: Whether to include a currency sign (default is false).
- `$decimal` *(bool)*: Whether to include decimals (default is false).
- `$thousend` *(string)*: Optional thousand separator.

**Returns:** A formatted `string` or percentage.

**Example:**

```
$formattedValue = numberFormatOrPercent('20%'); // '20%'
```

### `getPercentOfValue`

[](#getpercentofvalue)

Calculates the percentage of a given value.

**Parameters:**

- `$percentage` *(float|string)*: The percentage to calculate.
- `$amount` *(float|string)*: The amount to calculate the percentage of.
- `$percenSign` *(bool)*: Whether the percentage sign is included (default is true).

**Returns:** The calculated percentage of the amount.

**Example:**

```
$percentValue = getPercentOfValue('20%', 100); // 20
```

### `getValueOfPercent`

[](#getvalueofpercent)

Calculates the value based on a percentage of a given amount.

**Parameters:**

- `$percentage` *(float|string)*: The percentage value.
- `$amount` *(float|string)*: The amount to calculate the value from.

**Returns:** The calculated value based on the percentage.

**Example:**

```
$value = getValueOfPercent('25%', 200); // 50
```

### `getTimeFormat`

[](#gettimeformat)

Formats a given time into a specified format.

**Parameters:**

- `$time` *(string|DateTime)*: The time to format.
- `$format` *(string)*: The format to apply (default is 'Y-m-d H:i:s').

**Returns:** A formatted time `string`.

**Example:**

```
$formattedTime = getTimeFormat('now'); // e.g., '2024-10-05 15:00:00'
```

### `getTimeFormatJs`

[](#gettimeformatjs)

Formats a given time into a JavaScript-compatible format.

**Parameters:**

- `$time` *(string|DateTime)*: The time to format.

**Returns:** A JavaScript-compatible time `string`.

**Example:**

```
$jsTime = getTimeFormatJs('now'); // e.g., '2024-10-05T15:00:00Z'
```

### `getfirstAndLastName`

[](#getfirstandlastname)

Returns the first and last name from a full name string.

**Parameters:**

- `$fullName` *(string)*: The full name string.

**Returns:** An array containing the first and last names.

**Example:**

```
$names = getfirstAndLastName('John Doe'); // ['John', 'Doe']
```

### `getFolderSize`

[](#getfoldersize)

Calculates the size of a specified folder.

**Parameters:**

- `$dir` *(string)*: The path to the folder.

**Returns:** The size of the folder in bytes.

**Example:**

```
$size = getFolderSize('/path/to/folder'); // e.g., 2048
```

### `getFormatSize`

[](#getformatsize)

Formats a size in bytes into a more human-readable format.

**Parameters:**

- `$bytes` *(int)*: The size in bytes.

**Returns:** A formatted string representing the size.

**Example:**

```
$formattedSize = getFormatSize(2048); // '2 KB'
```

### `getCheckDevice`

[](#getcheckdevice)

Checks the user's device type.

**Returns:** A string representing the device type `(e.g., 'mobile', 'tablet', 'desktop')`.

**Example:**

```
$device = getCheckDevice(); // 'desktop'
```

### `getGenerateDepth`

[](#getgeneratedepth)

Generates the depth for nested structures.

**Parameters:**

- `$array` *(array)*: The array to calculate depth.

**Returns:** An integer representing the depth.

**Example:**

```
$depth = getGenerateDepth(['a' => ['b' => ['c']]]); // 3
```

### `convertPipeToArray`

[](#convertpipetoarray)

Converts a string with pipes into an array.

**Parameters:**

- `$string` *(string)*: The string to convert.

**Returns:** An array of values.

**Example:**

```
`$array` = convertPipeToArray('one|two|three'); // ['one', 'two', 'three']
```

### `convertNumberToWordInEnglish`

[](#convertnumbertowordinenglish)

Converts a number into words in English.

**Parameters:**

- `$number` *(int)*: The number to convert.

**Returns:** A string representing the number in words.

**Example:**

```
$words = convertNumberToWordInEnglish(123); // 'one hundred twenty-three'
```

### `getBanglaNumbers`

[](#getbanglanumbers)

Converts English numbers into Bangla numbers.

**Parameters:**

- `$number` *(int|string)*: The number to convert.

**Returns:** A string with Bangla numbers.

**Example:**

```
$banglaNumbers = getBanglaNumbers(123); // '১২৩'
```

### `convertNumberToWordInBangla`

[](#convertnumbertowordinbangla)

Converts a number into words in Bangla.

**Parameters:**

- `$number` *(int)*: The number to convert.

**Returns:** A string representing the number in Bangla words.

**Example:**

```
$banglaWords = convertNumberToWordInBangla(123); // 'একশত তেইশ'
```

### `generateRandomFloat`

[](#generaterandomfloat-1)

Generates a random floating-point number within a specified range.

**Parameters:**

- `$min` *(float)*: The minimum value of the range (inclusive).
- `$max` *(float)*: The maximum value of the range (inclusive).
- `$decimals` *(int)*: The number of decimal places (default is `2`).

**Returns:** A random float number between `$min` and `$max`.

**Example:**

```
$randomNumber = generateRandomFloat(1.0, 10.0); // e.g., 5.23
```

Contributing
------------

[](#contributing)

If you would like to contribute to this project, please fork the repository and submit a pull request.

License
-------

[](#license)

This project is licensed under the MIT License. See the LICENSE file for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance60

Regular maintenance activity

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~109 days

Total

4

Last Release

253d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6774a853b82e3460374fa933fecb393e8f59a915ff24548c71cf9ebf770e64e1?d=identicon)[rishadblack](/maintainers/rishadblack)

---

Top Contributors

[![rishadblack](https://avatars.githubusercontent.com/u/50762398?v=4)](https://github.com/rishadblack "rishadblack (9 commits)")

---

Tags

laravelhelpersRishad Black

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rishadblack-larahelpers/health.svg)

```
[![Health](https://phpackages.com/badges/rishadblack-larahelpers/health.svg)](https://phpackages.com/packages/rishadblack-larahelpers)
```

###  Alternatives

[laravel/helpers

Provides backwards compatibility for helpers in the latest Laravel release.

80660.2M456](/packages/laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
