Sending a value to Laravel controller

Get help using Construct 2

Post » Thu Mar 31, 2016 12:18 am

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', '[email protected]');

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 :)
B
5
Posts: 2
Reputation: 229

Post » Thu Mar 31, 2016 9:36 am

I hope it's OK, if I bump this. Still haven't been able to figure it out :(
B
5
Posts: 2
Reputation: 229


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, GrogIsGood, plinkie, rayolf and 6 guests