Git Product home page Git Product logo

laraveluserlogs's Introduction

LaravelUserLogs

Latest Stable Version Total Downloads License

This Laravel package allows you to store user logs. This package automatically stores the logs when a model is created, updated, or deleted.

Usage/Examples

Install Using Composer

composer require dipesh79/laravel-user-logs

Publish Vendor File For Migration

php artisan vendor:publish

And publish Dipesh79\LaravelUserLogs\LaravelLogServiceProvider

Run Migration

php artisan migrate

Model

Use HasLog Trait in your model. This will create a relation between your model and the Log model.

<?php

namespace App\Models;

use Dipesh79\LaravelUserLogs\Traits\HasLog;

class User extends Authenticatable
{
    use HasLog;

Automated Static events for logs

The Created, Updated, Deleted events are fired when a model is created, updated, or deleted, respectively. You don't have to do anything else, this package will automatically store the logs in the database.

Access User Logs

$logs = \Dipesh79\LaravelUserLogs\Models\Log::get();

V 1.4 update

View User Logs

Route::get('/logs', [Dipesh79\LaravelUserLogs\Controllers\UserLogController::class, 'index'])->name('logs');

Don't forget to guard this route with your custom or pre-defined middleware

V 1.4.1 update

Config File

    <?php

return [
    /**
     * Log Viewer Theme | Options: bootstrap.
     */

    'theme' => 'bootstrap',

    /**
     * Pagination Count.
     */
    'pagination' => 10,

    /**
     * User Identifier from users table.
     */
    'user_identifier' => 'name',

    /**
     * Return page from log view page.
     */
    'return_page' => [
        /**
         * Route Type | Options: route, url.
         */
        'route_type' => 'url',
        /**
         * Route Name or URL.
         */
        'url' => '/'
    ]

];

Chose theme for user log viewer. Currently only bootstrap theme is available. You can change the pagination count for user log viewer. You can change the user identifier from users table. By default it is name. You can change the return page from user log viewer. By default it is /. You can change it to your custom route or url.

V 1.5.0 Update

Now updated values will be stored in database and view them in user log viewer.

Get Access to Old Values And Updated Values in your model

    $user_log = \Dipesh79\LaravelUserLogs\Models\Log::find(1);
    $old_values = $user_log->old_data;
    $updated_values = $user_log->changed_values;

License

MIT

Author

Support

For support, email [email protected].

laraveluserlogs's People

Contributors

achyutkneupane avatar dipesh79 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

achyutkneupane

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.