Replies: 1 comment 1 reply
-
Dear @aledeg, you could actually work with the Here's a working example: $article = Article::firstOrFail();
$user = User::firstOrFail();
Like::add($article, $user)->touch(); Please let me know if that works! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
I am using a custom
Mark
class to handle recently viewed items. This class is called through an event in some of my controllers. The table is properly handled as I can see items piling in there as soon as they are triggered.Encountered problems
When I trigger the controller for the same model multiple times, it's always the first one that is kept. It means I have no way to know when was the last time I visited a model.
My first though was to handle that with a
Recent::remove
followed byRecent::add
. This works but that means that my ids will increase rapidly.I then tried to handle that through
Recent::toggle
but I have the exact same problem.Current solution
I used a manual update to do such thing with something similar to the following:
This works but it's not very elegant.
Feature request
I think this could be handled directly at the library level with some custom method on the
Mark
class. Something similar toMark::addOrUpdate($markable, $user)
. ButMark::update($markable, $user)
would work fine too.Beta Was this translation helpful? Give feedback.
All reactions