PHPackages                             satya/eloquent-activity - 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. satya/eloquent-activity

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

satya/eloquent-activity
=======================

This will manage the eloquent activity and save to database

v1.0.0(5y ago)666MITPHP

Since Dec 31Pushed 5y agoCompare

[ Source](https://github.com/satyaprakash-nishad/eloquent-activity)[ Packagist](https://packagist.org/packages/satya/eloquent-activity)[ RSS](/packages/satya-eloquent-activity/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (4)Used By (0)

[![Laravel Eloquent Activity Manage Package](src/images/main_image.png)](src/images/main_image.png)

Laravel Eloquent Activity Manage Package
----------------------------------------

[](#laravel-eloquent-activity-manage-package)

This will manage the eloquent activity and save to database and developer can be easily manage the laravel app activity.

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

[](#installation)

Package installation using composer

```
composer require satya/eloquent-activity

```

Register service provider in your config/app.php file:

```
'providers' => [
    // ...
    Satya\EloquentActivity\EloquentActivityServiceProvider::class,
];

```

Run the migrations:

```
php artisan migrate
```

Basic Usage
-----------

[](#basic-usage)

First, add the Satya\\EloquentActivity\\Traits\\EloquentActivity trait to your model(s):

```
use Illuminate\Database\Eloquent\Model;
use Satya\EloquentActivity\Traits\EloquentActivity;

class VendorCenter extends Model
{
    use EloquentActivity;

    //..
}

```

Custom Eloquent Tag Name Setup
------------------------------

[](#custom-eloquent-tag-name-setup)

By default, the package uses the log name as an eloquent name. For example, VendorCenter is the class name, so the log tag name considers as “Vendor Center”. If you went customize tag name just use declare the protected variable tagName in the model class body.

```
protected $tagName = 'Vendor Information';

```

```
use Illuminate\Database\Eloquent\Model;
use Satya\EloquentActivity\Traits\EloquentActivity;

class VendorCenter extends Model
{
    use EloquentActivity;

    protected $tagName = 'Vendor Information';

    //..
}

```

Retrieve App Activity
---------------------

[](#retrieve-app-activity)

For retrieving app activity just use the Satya\\EloquentActivity\\Model\\EloquentActivity model.

```
use Satya\EloquentActivity\Model\EloquentActivity;

class VendorCenterController extends Controller
{

    public function index(){
        //Retrieving app activity
        $activity = EloquentActivity::orderBy('created_at','DESC')->get();
    }
}

```

Example to retrieving specific record history
---------------------------------------------

[](#example-to-retrieving-specific-record-history)

This package has features to view the specific record history by calling the recordHistory morphMany relationship method.

- Controller ```
     /**
         * @param $id
         */
        public function history($id){
            $client = Client::where('id',$id)->first();
            if (!empty($client))
            {
                dump($client);
                dd($client->recordHistory->toArray());
            }
        }
    ```
- Model ```
