Dear friend I suggest you to create a table of logs
where you bind by id
user to the activity performed by the user. Example:
- Create a Model for the Logs table.
- Create a Helper that you can call on any
Controller.
- Create default descriptions for each activity be it one
insert
,
update
among others...
Example Model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SystemLogs extends Model
{
}
Example Helper:
<?php
namespace App\Helpers;
class LogsHelper
{
public function saveLog($acivity){
...
}
}
Example Controller:
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Helpers\LogsHelper;
class MyController extends BaseController
{
public function add(){
...
}
public function save(){
...
}
}
Of course I’m not going to program for you, I’m just passing on an idea of logging very simple user activities. In this case you can save in the log table the name of the changed table, the id of the record created, changed or deleted linked to the user id. This is very useful in audits.
Thank you very much, it worked! I tested this logic with what I had thought and it worked, thank you!
– brunoelyg
@brunoelyg would have how to share his code? I understood the logic but as I’m beginner in Laravel I can’t get out of place. :/
– Lara Gallassi