How to use Laravel to promote students from one grade to another

Published

I have a raw php code which promote students from one grade to another upon a submission and it works fine. I want to use Laravel to do that and I seem not to get it. I need assistance and to learn from it.

public function updateClass() {

    $QueryStudent  = "
    UPDATE students
    SET CurrentClass = (
    CASE CurrentClass
      WHEN 'Grade 1' THEN 'Grade 2'
      WHEN 'Grade 2' THEN 'Grade 3'                                               
      WHEN 'Grade 3' THEN 'Grade 4'                                                  
      WHEN 'Grade 4' THEN 'Grade 5'                                                     
      WHEN 'Grade 5' THEN 'Grade 6'                                                                                                                                            
      WHEN 'Grade 6' THEN 'Graduate'                                         
    END
    )
    WHERE CurrentClass IN ('Grade 1', 'Grade 2', 'Grade 3', 'Grade 4', 'Grade 5', 'Grade 6')";

    $StudentStmt = $Connection->query($QueryStudent);
}

Source: Laravel

Published
Categorised as laravel, mysql, php Tagged , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq