-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from AmanRawat2001/User-Activity-Log
adding the activity logs of the user in the User Controller only
- Loading branch information
Showing
14 changed files
with
412 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Spatie\Activitylog\Models\Activity; | ||
|
||
class ActivityController extends Controller | ||
{ | ||
// | ||
public function index() | ||
{ | ||
$activities = Activity::paginate(10); | ||
|
||
return view('activity_log.index', compact('activities')); | ||
} | ||
public function all() | ||
{ | ||
$activities = Activity::all(); | ||
|
||
return view('activity_log.all', compact('activities')); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
* If set to false, no activities will be saved to the database. | ||
*/ | ||
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true), | ||
|
||
/* | ||
* When the clean-command is executed, all recording activities older than | ||
* the number of days specified here will be deleted. | ||
*/ | ||
'delete_records_older_than_days' => 365, | ||
|
||
/* | ||
* If no log name is passed to the activity() helper | ||
* we use this default log name. | ||
*/ | ||
'default_log_name' => 'default', | ||
|
||
/* | ||
* You can specify an auth driver here that gets user models. | ||
* If this is null we'll use the current Laravel auth driver. | ||
*/ | ||
'default_auth_driver' => null, | ||
|
||
/* | ||
* If set to true, the subject returns soft deleted models. | ||
*/ | ||
'subject_returns_soft_deleted_models' => false, | ||
|
||
/* | ||
* This model will be used to log activity. | ||
* It should implement the Spatie\Activitylog\Contracts\Activity interface | ||
* and extend Illuminate\Database\Eloquent\Model. | ||
*/ | ||
'activity_model' => \Spatie\Activitylog\Models\Activity::class, | ||
|
||
/* | ||
* This is the name of the table that will be created by the migration and | ||
* used by the Activity model shipped with this package. | ||
*/ | ||
'table_name' => 'activity_log', | ||
|
||
/* | ||
* This is the database connection that will be used by the migration and | ||
* the Activity model shipped with this package. In case it's not set | ||
* Laravel's database.default will be used instead. | ||
*/ | ||
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'), | ||
]; |
27 changes: 27 additions & 0 deletions
27
database/migrations/2024_09_24_191240_create_activity_log_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateActivityLogTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->string('log_name')->nullable(); | ||
$table->text('description'); | ||
$table->nullableMorphs('subject', 'subject'); | ||
$table->nullableMorphs('causer', 'causer'); | ||
$table->json('properties')->nullable(); | ||
$table->timestamps(); | ||
$table->index('log_name'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name')); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_09_24_191241_add_event_column_to_activity_log_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class AddEventColumnToActivityLogTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->string('event')->nullable()->after('subject_type'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->dropColumn('event'); | ||
}); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_09_24_191242_add_batch_uuid_column_to_activity_log_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class AddBatchUuidColumnToActivityLogTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->uuid('batch_uuid')->nullable()->after('properties'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) { | ||
$table->dropColumn('batch_uuid'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
http://127.0.0.1:5173 | ||
http://[::1]:5173 |
Oops, something went wrong.