|
9 | 9 | This Laravel package allows you to store user logs. |
10 | 10 | This package automatically stores the logs when a model is created, updated, or deleted. |
11 | 11 |
|
12 | | -## Usage/Examples |
| 12 | +## Quick Start |
13 | 13 |
|
14 | 14 | ### Install Using Composer |
15 | 15 |
|
16 | 16 | ```bash |
17 | 17 | composer require dipesh79/laravel-user-logs |
18 | 18 | ``` |
| 19 | +## Official Documentation |
19 | 20 |
|
20 | | -### Publish Vendor File For Migration |
21 | | - |
22 | | -```bash |
23 | | -php artisan vendor:publish |
24 | | -``` |
25 | | - |
26 | | -And publish `Dipesh79\LaravelUserLogs\LaravelLogServiceProvider` |
27 | | - |
28 | | -### Run Migration |
29 | | - |
30 | | -```bash |
31 | | -php artisan migrate |
32 | | -``` |
33 | | - |
34 | | -## Model |
35 | | - |
36 | | -Use ```HasLog``` Trait in your model. This will create a relation between your model and the `Log` model. |
37 | | - |
38 | | -```php |
39 | | -<?php |
40 | | - |
41 | | -namespace App\Models; |
42 | | - |
43 | | -use Dipesh79\LaravelUserLogs\Traits\HasLog; |
44 | | - |
45 | | -class User extends Authenticatable |
46 | | -{ |
47 | | - use HasLog; |
48 | | -``` |
49 | | - |
50 | | -### Automated Static events for logs |
51 | | - |
52 | | -The `Created`, `Updated`, `Deleted` events are fired when a model is created, updated, or deleted, respectively. |
53 | | -You don't have to do anything else, this package will automatically store the logs in the database. |
54 | | - |
55 | | - |
56 | | -### Access User Logs |
57 | | -```php |
58 | | -$logs = \Dipesh79\LaravelUserLogs\Models\Log::get(); |
59 | | -``` |
60 | | - |
61 | | -### V 1.4 update |
62 | | - |
63 | | -View User Logs |
64 | | -``` |
65 | | -Route::get('/logs', [Dipesh79\LaravelUserLogs\Controllers\UserLogController::class, 'index'])->name('logs'); |
66 | | -``` |
67 | | -Don't forget to guard this route with your custom or pre-defined middleware |
68 | | - |
69 | | -### V 1.4.1 update |
70 | | - |
71 | | -## Config File |
72 | | - |
73 | | -```php |
74 | | - <?php |
75 | | - |
76 | | -return [ |
77 | | - /** |
78 | | - * Log Viewer Theme | Options: bootstrap. |
79 | | - */ |
80 | | - |
81 | | - 'theme' => 'bootstrap', |
82 | | - |
83 | | - /** |
84 | | - * Pagination Count. |
85 | | - */ |
86 | | - 'pagination' => 10, |
87 | | - |
88 | | - /** |
89 | | - * User Identifier from users table. |
90 | | - */ |
91 | | - 'user_identifier' => 'name', |
92 | | - |
93 | | - /** |
94 | | - * Return page from log view page. |
95 | | - */ |
96 | | - 'return_page' => [ |
97 | | - /** |
98 | | - * Route Type | Options: route, url. |
99 | | - */ |
100 | | - 'route_type' => 'url', |
101 | | - /** |
102 | | - * Route Name or URL. |
103 | | - */ |
104 | | - 'url' => '/' |
105 | | - ] |
106 | | - |
107 | | -]; |
108 | | -``` |
109 | | - |
110 | | -Chose theme for user log viewer. Currently only bootstrap theme is available. |
111 | | -You can change the pagination count for user log viewer. |
112 | | -You can change the user identifier from users table. By default it is `name`. |
113 | | -You can change the return page from user log viewer. By default it is `/`. You can change it to your custom route or |
114 | | -url. |
115 | | - |
116 | | -### V 1.5.0 Update |
117 | | -Now updated values will be stored in database and view them in user log viewer. |
118 | | - |
119 | | -Get Access to Old Values And Updated Values in your model |
120 | | -```php |
121 | | - $user_log = \Dipesh79\LaravelUserLogs\Models\Log::find(1); |
122 | | - $old_values = $user_log->old_data; |
123 | | - $updated_values = $user_log->changed_values; |
124 | | - |
125 | | -``` |
126 | | - |
| 21 | +Documentation can be found on my [website](https://khanaldipesh.com.np/package/laravel-user-logs). |
127 | 22 |
|
128 | 23 | ## License |
129 | 24 |
|
|
0 commit comments