Reddit Style Vote (incomplete)

  1. 4 years ago
    Edited 4 years ago by Niuwang

    Meh, I'm bored and I figured I'd do this but I'm not 100% up for creating it.....cause lazy. I made a basic laravel code for a function. If someone wants to takeover idc really. Although if nobody wants to then I'll do it. .-. just a kickstart for the most part...

    function vote()
    {    
        if (Auth::check()) {
    
            if (Request::ajax())
            {
                $post = Input::post('post');
                $vote = Input::post('vote');
                $user = Auth::user()->id;
    
                // Grab the vote if it already exists.
                $entry = Vote::where('user_id', $user)->where('post_id', $post)->first();
    
                if ($entry->count())
                {
                    $entry->vote = $vote;
                    $entry->save();
                }
                else
                {
                    $entry = new Vote;
                    $entry->user_id = $user;
                    $entry->post_id = $post;
                    $entry->save();
                }
            }
            else
            {
                return "Not an AJAX request.";
            }
        }
        else
        {
            return "User not logged in.";
        }
    }
  2. 3 years ago

    So have you gotten any closer to completing this yet? xD

  3. No i actually totally forgot about it. Busy getting my life together and trying to buy a new laptop and desktop.

    Not to mention full time student. So no real time for anything.

  4. Full time student.. god, if only you would know how hard real life is ;)

  5. @Tristan Full time student.. god, if only you would know how hard real life is ;)

    I got a taste of real life last year which is why I'm gettting my life together....

  6. 2 years ago

    [deleted]

    16 Jul 2016

    @Tristan Full time student.. god, if only you would know how hard real life is ;)

    He didn't even say what type of student he was. He could be in engineering, physics, or medical school. Don't be so ignorant.

  7. [deleted]

    17 Jul 2016

    hello.test.

 

or Sign Up to reply!