PHPackages                             drands/laravel-utils - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. drands/laravel-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

drands/laravel-utils
====================

A collection of Laravel utilities created by De Ramos &amp; Serch.

1.0.8(6mo ago)0134↓75%MITPHPPHP &gt;=8.1

Since Jul 8Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/drands/laravel-utils)[ Packagist](https://packagist.org/packages/drands/laravel-utils)[ RSS](/packages/drands-laravel-utils/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

Drands Laravel Utils
====================

[](#drands-laravel-utils)

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

[](#installation)

```
composer require drands/laravel-utils
```

Utils
-----

[](#utils)

### DeleteOnCascade Trait

[](#deleteoncascade-trait)

This trait can be used to automatically delete related models when a parent model is deleted. It leverages Laravel's model events to listen for deletions and cascade the delete operation to related models.

#### Usage

[](#usage)

To use this trait, you need to include it in your Eloquent model:

```
use Drands\LaravelUtils\Traits\DeleteOnCascade;

class Post extends Model
{
    use DeleteOnCascade;

    protected $deleteOnCascade = ['mediaItems'];
}
```

### HasBuilder Trait

[](#hasbuilder-trait)

This trait provides functionality to manage media files associated with a model that uses a builder pattern. It ensures that media files are properly deleted when the model is deleted.

#### Usage

[](#usage-1)

To use this trait, you need to include it in your Eloquent model:

```
use Drands\LaravelUtils\Traits\HasBuilder;

class Post extends Model
{
    use HasBuilder;

    protected $builders = ['body'];
}
```

### HasUploads Trait

[](#hasuploads-trait)

This trait provides functionality to manage file uploads associated with a model. It ensures that uploaded files are properly deleted when the model is deleted.

#### Usage

[](#usage-2)

To use this trait, you need to include it in your Eloquent model:

```
use Drands\LaravelUtils\Traits\HasUploads;

class Post extends Model
{
    use HasUploads;

    protected $uploadFields = ['file'];
}
```

### CloneTranslations (Filament Action)

[](#clonetranslations-filament-action)

This utility provides a Filament action to clone translations from one language to another. It allows you to select the source language, target languages, and specific fields to clone.

#### Usage

[](#usage-3)

To use this utility, you need to include the action in your Filament resource:

```
use Drands\LaravelUtils\Filament\Actions\CloneTranslations;

public static function getActions(): array
{
    return [
        CloneTranslations::make()
            ->builderFields(['body']), // Specify the builder fields
    ];
}
```

### Helpers

[](#helpers)

#### getFileExtension($filePath)

[](#getfileextensionfilepath)

This helper function retrieves the file extension from a given file path.

#### isValidFileExtension($filePath, Array $validExtensions)

[](#isvalidfileextensionfilepath-array-validextensions)

This helper function checks if the file extension of the given file path is valid based on the provided list of valid extensions.

#### isImageFile($filePath)

[](#isimagefilefilepath)

This helper function checks if the given file path is an image file based on its extension.

#### isVideoFile($filePath)

[](#isvideofilefilepath)

This helper function checks if the given file path is a video file based on its extension.

#### getCurrentGitCommitHash()

[](#getcurrentgitcommithash)

This helper function retrieves the current Git commit hash of the project.

#### media\_embed($id, $host, $attributes = \[\], $params = \[\])

[](#media_embedid-host-attributes---params--)

This helper function generates an HTML embed code for a media file.

#### money\_format($number, $showZeros = true, $decimals = 2, $showCurrency = true)

[](#money_formatnumber-showzeros--true-decimals--2-showcurrency--true)

This helper function formats a number as a monetary value.

#### setting($key, $default = null)

[](#settingkey-default--null)

This helper function retrieves the value of a specific setting.

#### uploadFileNamer(TemporaryUploadedFile $file, $disk = 'public')

[](#uploadfilenamertemporaryuploadedfile-file-disk--public)

This helper function generates a unique name for an uploaded file.

#### pageShow($slug = '')

[](#pageshowslug--)

```
Route::get('/about', pageShow('about'))->name('about');
```

This helper function allows you to create a route for the "show" page of a given resource.

#### pageIndex($slug = '')

[](#pageindexslug--)

```
Route::get('/about', pageIndex('about'))->name('about');
```

This helper function allows you to create a route for the "index" page of a given resource.

#### imageUrl($filename = '')

[](#imageurlfilename--)

This helper function generates a URL for a given image file if it exists, otherwise it returns a default placeholder image URL.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance69

Regular maintenance activity

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% 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 ~24 days

Total

8

Last Release

183d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cc8e65968f889dff8d685730d1ad08ae5d153f07d21f3aa36262960be182033?d=identicon)[drands](/maintainers/drands)

---

Top Contributors

[![daniouyea](https://avatars.githubusercontent.com/u/1612938?v=4)](https://github.com/daniouyea "daniouyea (10 commits)")[![jesusmarinjaca](https://avatars.githubusercontent.com/u/228337631?v=4)](https://github.com/jesusmarinjaca "jesusmarinjaca (1 commits)")

### Embed Badge

![Health badge](/badges/drands-laravel-utils/health.svg)

```
[![Health](https://phpackages.com/badges/drands-laravel-utils/health.svg)](https://phpackages.com/packages/drands-laravel-utils)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

9782.1M161](/packages/laravel-ai)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

721160.4k12](/packages/tallstackui-tallstackui)[zidbih/laravel-deadlock

Make temporary Laravel workarounds expire and fail CI when ignored.

984.0k](/packages/zidbih-laravel-deadlock)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

19253.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

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