0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel用アクティビティログライブラリを作りました!!

Last updated at Posted at 2023-08-24

こんにちは,ご覧いただきありがとうございます。

Laravel用のアクティビティログライブラリを作成しました。

機能

  • ユーザーのアクティビティを記録
  • ログイン中ユーザーのアクティビティを表示

特徴

  • ユーザーごとのアクティビティ履歴を保存できます
  • ユーザーごとにアクティビティ履歴を表示できます

インストール

1.composerでインストール

composer require ikepu-tp/laravel-activity-log

2.設定ファイルの設定

php artisan vendor:publish --tag=ActivityLog-config

3.マイグレーション

php artisan migrate

4.ミドルウェアを追加

app\Http\Kernel
    protected $middleware = [
        // \App\Http\Middleware\TrustHosts::class,
        \App\Http\Middleware\TrustProxies::class,
        \Illuminate\Http\Middleware\HandleCors::class,
        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+       \ikepu_tp\ActivityLog\app\Http\Middleware\ActivityLogMiddleware::class,
    ];

これでインストールは終了です。
http://localhost/activity-logにアクセスしてみてください。
あなたのアクティビティが表示されていると思います。

もし/activity-logを変更したい場合,ルーティングを変更してください。

/route/activity-log.php
Route::group([
    "middleware" => "auth"
], function () {
    Route::get("activity-log", [ActivityLogController::class, "index"])->name("activity-log.index");
                // ↑ここを変更してください。
});

5. アクティビティの登録

設定ファイル(/config/activity-log.php)のactivitiesを編集し,アクティビティを設定してください。

今後の更新予定

とりあえず公開したという感じなので今後も機能追加していきたいと思います。
よければGithubのスターやフォローをお願いします!
もちろん,プルリクもお待ちしています!!

更新履歴

  • 公開しました
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?