| Server IP : 54.233.248.239 / Your IP : 172.28.20.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/vinumday2_0/vendor/spatie/laravel-activitylog/ |
Upload File : |
# Log activity inside your Laravel app
[](https://packagist.org/packages/spatie/laravel-activitylog)
[](https://travis-ci.org/spatie/laravel-activitylog)
[](https://scrutinizer-ci.com/g/spatie/laravel-activitylog)
[](https://styleci.io/repos/61802818)
[](https://packagist.org/packages/spatie/laravel-activitylog)
The `spatie/laravel-activitylog` package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events. All activity will be stored in the `activity_log` table.
Here's a litte demo of how you can use it:
```php
activity()->log('Look, I logged something');
```
You can retrieve all activity using the `Spatie\Activitylog\Models\Activity` model.
```php
Activity::all();
```
Here's a more advanced example:
```php
activity()
->performedOn($anEloquentModel)
->causedBy($user)
->withProperties(['customProperty' => 'customValue'])
->log('Look, I logged something');
$lastLoggedActivity = Activity::all()->last();
$lastLoggedActivity->subject; //returns an instance of an eloquent model
$lastLoggedActivity->causer; //returns an instance of your user model
$lastLoggedActivity->getExtraProperty('customProperty'); //returns 'customValue'
$lastLoggedActivity->description; //returns 'Look, I logged something'
```
Here's an example on [event logging](https://docs.spatie.be/laravel-activitylog/v1/advanced-usage/logging-model-events).
```php
$newsItem->name = 'updated name';
$newsItem->save();
//updating the newsItem will cause an activity being logged
$activity = Activity::all()->last();
$activity->description; //returns 'updated'
$activity->subject; //returns the instance of NewsItem that was created
```
Calling `$activity->changes` will return this array:
```php
[
'attributes' => [
'name' => 'updated name',
'text' => 'Lorum',
],
'old' => [
'name' => 'original name',
'text' => 'Lorum',
],
];
```
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).
## Postcardware
You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciated you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
All postcards are published [on our website](https://spatie.be/en/opensource/postcards).
## Documentation
You'll find the documentation on [https://docs.spatie.be/laravel-activitylog/v1](https://docs.spatie.be/laravel-activitylog/v1).
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the activity log? Feel free to [create an issue on GitHub](https://github.com/spatie/laravel-activitylog/issues), we'll try to address it as soon as possible.
If you've found a bug regarding security please mail [freek@spatie.be](mailto:freek@spatie.be) instead of using the issue tracker.
## Installation
You can install the package via composer:
``` bash
composer require spatie/laravel-activitylog
```
Next, you must install the service provider:
```php
// config/app.php
'providers' => [
...
Spatie\Activitylog\ActivitylogServiceProvider::class,
];
```
You can publish the migration with:
```bash
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="migrations"
```
*Note*: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the subject_id and causer_id fields in the published migration before continuing.
After the migration has been published you can create the `activity_log` table by running the migrations:
```bash
php artisan migrate
```
You can optionally publish the config file with:
```bash
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"
```
This is the contents of the published config file:
```php
return [
/**
* When set to false, no activities will be saved to database.
*/
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true),
/**
* When running the clean-command all recording activites older than
* the number of days specified here will be deleted.
*/
'delete_records_older_than_days' => 365,
/**
* When not specifying a log name when logging activity
* we'll using this log name.
*/
'default_log_name' => 'default',
/**
* When set to true, the subject returns soft deleted models.
*/
'subject_returns_soft_deleted_models' => false,
/**
* This model will be used to log activity. The only requirement is that
* it should be or extend the Spatie\Activitylog\Models\Activity model.
*/
'activity_model' => \Spatie\Activitylog\Models\Activity::class,
];
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
## Credits
- [Freek Van der Herten](https://github.com/freekmurze)
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)
## About Spatie
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.