Hello,
My scenario is I have three models. User, Track & Vote.
The idea is that a user can "vote" a track. So there are obviously some relations. What I want to do, is if a user "votes" for the track, insert a new vote into my table. I currently have this working like so.
$track->votes()->firstOrCreate(['user_id' => $user->id]);
What I want to do, is if the record already exists - meaning the user has already voted for the track - delete the vote. Otherwise create one.
I hope this makes sense, any ideas how I can achieve this?
I also don't belive I'm at liberty to use a pivot table as there are three models.
Thanks