PHPackages                             digitalcloud/eloquent-custom-actions - 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. [Database &amp; ORM](/categories/database)
4. /
5. digitalcloud/eloquent-custom-actions

ActiveLibrary[Database &amp; ORM](/categories/database)

digitalcloud/eloquent-custom-actions
====================================

Laravel Eloquent Custom Actions, make it easier to simulate eloquent events for custom actions.

v0.2(7y ago)23MITPHPPHP &gt;=7.1.0

Since Jan 2Pushed 7y ago4 watchersCompare

[ Source](https://github.com/DigitalCloud/eloquent-custom-actions)[ Packagist](https://packagist.org/packages/digitalcloud/eloquent-custom-actions)[ RSS](/packages/digitalcloud-eloquent-custom-actions/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Laravel Eloquent Custom Actions.
================================

[](#laravel-eloquent-custom-actions)

The package idea inspired from laravel eloquent events functionallity and eloquent scope code style. If you like the Event driven development approach, this package can dramatically clean your model code.

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

[](#installation)

You can install the package via composer:

```
composer require digitalcloud/eloquent-custom-actions
```

Usage Example
-------------

[](#usage-example)

Without this package, to simulate the eloquent events, you will end with:

```
class User extends Authenticatable

    public function verify($mobile)
    {
        $userMobile = new UserMobile([
            'mobile' => $mobile, 'status' => self::STATUS_VERIFIED
        ]);

        if(app()->events->until(
            event(new MobileVerifying($userMobile)) !== false
        )){
            $userMobile = $this->mobiles()->save($userMobile);
            event(new MobileVerified($userMobile));
            return $userMobile;
        }

        return false;
    }
}
```

To simplify your `User` model, declare `action{MethodName}` method and remove all event related codes, the package will automatically fire `before{Method}` and `after{Method}` events when `$user->verify($mobile)` invoked.

```
