feat/ISSUE-11-add-logging #23
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/ISSUE-11-add-logging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#14
@ -0,0 +13,4 @@{Schema::create('logs', function (Blueprint $table) {$table->id();$table->foreignIdFor(User::class)->nullable();Probably doesn't matter but might be a good idea to add constrains onto these for Foreign Keys?
Or maybe use a morphable since there's a lot of targets here?
https://laravel.com/docs/10.x/eloquent-relationships#polymorphic-relationships
Or maybe use this off the shelf library?
https://spatie.be/docs/laravel-activitylog/v4/introduction
I do like the ldea of morphable, I was talking with about about using something like this for transactions too when we eventually add things that aren't quotes so we can track it
@ -0,0 +16,4 @@$table->foreignIdFor(User::class)->nullable();$table->foreignIdFor(Quote::class)->nullable();$table->foreignIdFor(RequestedQuote::class)->nullable();$table->string('content');Unsure how long the content might need to be, but might be good as a text column?
@llama
If you are going to use a morphable for this, I would highly recommend setting up a Morph Map instead of using the class names for the morphable types.
https://laravel.com/docs/10.x/eloquent-relationships#custom-polymorphic-types
That way it's not tied to the exact location of the models.
I also think you should create two nullable morphs instead of just one here, one for the "subject" and one for the "actor" / "causer", that way you can then basically log when any model causes another model to do something.
In most causes the "causer" would either be the user submitting a request or accepting the request, which right now is a single model, but could be anything going forward.
Having "Causer" be nullable should allow you to log "system" type actions as well, from crons or anything else too.
Checking if emojis still kill the DB 💯
At some point we'll probs want to look into sorting and filtering but for now this gives up all the info we need I think