Show an activity log on a Vue page

Log the subject and the user from the controller. Pass the latest rows as a prop. Do not log a password.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-activity-log-vue.md
Log the subject and the user from the controller. Pass the latest rows as a prop. Do not log a password.
Do not put the properties JSON on a page any user can open until you have read what you stored.
Do not log attribute changes on User without an except list.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel activity log Vue” install a package and then log $request->all(). That stores the password. Log a sentence and the subject. The policy guide is who may open the page that lists those rows.

TL;DR

  • Log the subject and the user from the controller.
  • Pass the latest rows as a prop.
  • Do not log a password.
  • Do not put the properties JSON on a page any user can open until you have read what you stored.

Who it's for: Laravel + Vue developers

Applies to: Laravel 13 · Vue 3

The fix#

Spatie’s package is the one this search usually means:

shell
composer require spatie/laravel-activitylog
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
php artisan migrate
php
activity()
    ->performedOn($post)
    ->causedBy($request->user())
    ->log('updated the post');

Pass the latest rows to an admin page only:

php
'activity' => Activity::query()->latest('id')->limit(20)->get(['id', 'description', 'created_at']),

What to avoid#

Gotcha

Do not put the properties JSON on a page any user can open until you have read what you stored. Do not log attribute changes on User without an except list. Tokens and passwords do not belong in activity_log.

FAQ#

How do I show an activity log on a Vue page?

Log the subject and the user from the controller. Pass the latest rows as a prop. Do not log a password.

What goes wrong with Laravel activity log Vue?

Many developers install a package and then log $request->all(). Do not put the properties JSON on a page any user can open until you have read what you stored.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.