Sending a value to Laravel controller

0 favourites
  • 2 posts
From the Asset Store
Small pixel icons for the 3 most popular controller types.
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I hope it's OK, if I bump this. Still haven't been able to figure it out

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)