Laravel package to log each user's activity in the system.
storeActivity('user type' , 'User Action', 'Description');
Require this package with composer.
composer require mark-villudo/activity-logs
Make model with migration file at the same time.
Note: At the package the model used is under "App\Models" then please do so.
php artisan make:model Models/ActivityLog -m
Activity Logs Table Structure
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateActivityLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('activity_logs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('user_id')->nullable();
$table->string('type', 32)->nullable();
$table->text('action'); //required
$table->text('description')->nullable();
$table->string('ip_address', 64)->nullable();
$table->text('device')->nullable();
$table->text('platform')->nullable();
$table->text('browser')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('activity_logs');
}
}
Migrate table using composer and it's automatically create table in the database
php artisan migrate
//Parameter details (userType , action, description)
storeActivity('Admin', 'Update Profile', 'Update Profile Settings');
The MIT License (MIT). Please see License File for more information.