Hello This might be a little specific, but I hope I can get some help.
I'm currently making a website with Laravel to host my game and I would like registered users to have achievements saved on their profile. So I have a users table and an achievement table in my database, and a pivot table that has two columns with user id and achievement id. Now I would like to send information (I presume with AJAX) on a certain event to my controller that creates an entry into the pivot table when a user collects an achievement.
So in my framework I have a route:
Route::post('achievements', 'AchievementsController@achievement');
That points to a controller:
class AchievementsController extends Controller
{
public function achievement()
{
$burek = new Achievement_User;
$burek->achievement_id= ??????;
$burek->user_id= Auth::user()->id;
$burek->save();
}
}
And in C2 AJAX I just enter URL "achievements") and it points to the right controller (tested with a GET request and it worked perfectly)
But I don't know how to send in the part with the question marks? I can't figure out how to send a POST request that would fill in the question marks.
If anyone can help, it will be much appreciated.
PS: I'm not a coder/programmer, so please explain everything like you are talking to a 6 yaer-old