mardi 18 juillet 2017

Get next and previous records in laravel

how to get next and previous records using buttons instead of href,

for example

     <form method="post" action="/">
        //Question and options will come here,
       //when click on next button next question should appear and if I click on prev button it should goto prev question
     <button type ="submit">Next Question
     <button type ="submit">Previous Question
     </form>

my Controller

     $questions = Question::find($qId);
     $options = Question::find($qId)->options;
     $previous = Question::where('id', '<', $questions->id)->max('id');
     $next = Question::where('id', '>', $questions->id)->min('id');
     return view('Pages/User/Questions/Question2')
                                ->with('options',$options)
                                ->with('questions',$questions)
                                ->with('previous',Question::find($previous))
                                ->with('next',Question::find($next));

Now How to send next and prev id on the button submit.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2u4H0GL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire