PHPackages                             sme/laravel-model-life-events - 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. sme/laravel-model-life-events

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

sme/laravel-model-life-events
=============================

08PHP

Since Apr 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/SergoMorello/laravel-model-events)[ Packagist](https://packagist.org/packages/sme/laravel-model-life-events)[ RSS](/packages/sme-laravel-model-life-events/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-model-events
====================

[](#laravel-model-events)

This library allows you to extend the work of Models life cycle methods in Laravel Framework
--------------------------------------------------------------------------------------------

[](#this-library-allows-you-to-extend-the-work-of-models-life-cycle-methods-in-laravel-framework)

### Install:

[](#install)

```
composer require sme/laravel-model-life-events

```

### For example:

[](#for-example)

```
class Posts extends Model
{
	public static function booted() {

		self::deleted(function (self $model) {

			//  listening to the deletion event in the current model
			...

		});

	}
```

#### For this code, the listener will not work because the method calling the deleted event is missing from the Builder class

[](#for-this-code-the-listener-will-not-work-because-the-method-calling-the-deleted-event-is-missing-from-the-builder-class)

```
public static function deletePost(int $post_id) {
	return self::where('id', $post_id)->delete();
}
```

#### you can use the find($post\_id) method then everything will work, but it is not always convenient

[](#you-can-use-the-findpost_id-method-then-everything-will-work-but-it-is-not-always-convenient)

```
public static function deletePost(int $post_id) {
	$post = self::find($post_id);
	if ($post) {
		return $post->delete();
	}
}
```

#### To use the delete or update methods without additional first, find, etc. methods. You can use trait "HasEvents" in your models class

[](#to-use-the-delete-or-update-methods-without-additional-first-find-etc-methods-you-can-use-trait-hasevents-in-your-models-class)

```
use SME\Laravel\Model\HasEvents;

class Posts extends Model
{
	use HasEvents;

	...
```

#### In this case, listeners such as "deleting" or "updating" are always called, and "deleted" or "updated" are called only if the request was successful

[](#in-this-case-listeners-such-as-deleting-or-updating-are-always-called-and-deleted-or-updated-are-called-only-if-the-request-was-successful)

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/34d9c406e0531b61b66611a641819982ae6648a5584e6dea5f13f9c53b543477?d=identicon)[SergoMorello](/maintainers/SergoMorello)

---

Top Contributors

[![SergoMorello](https://avatars.githubusercontent.com/u/44141734?v=4)](https://github.com/SergoMorello "SergoMorello (7 commits)")

### Embed Badge

![Health badge](/badges/sme-laravel-model-life-events/health.svg)

```
[![Health](https://phpackages.com/badges/sme-laravel-model-life-events/health.svg)](https://phpackages.com/packages/sme-laravel-model-life-events)
```

PHPackages © 2026

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