Advertisement
muhidins

controller

Feb 6th, 2021 (edited)
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. namespace App\Controllers;
  3.  
  4. /**
  5.  * by Muhidin Saimin
  6.  * 06/02/2021
  7.  */
  8.  
  9. use CodeIgniter\Controller;
  10. use App\Models\GradeModel;
  11.  
  12. class Grade extends Controller
  13. {
  14.     public function index()
  15.     {
  16.         $model = new GradeModel();
  17.         $data['grades'] = $model->orderBy('name', 'ASC')->findAll();
  18.         return view('grades/index', $data);
  19.     }
  20.  
  21.     public function add()
  22.     {
  23.         helper(['url', 'form']);
  24.         $model = new GradeModel();
  25.        
  26.         return view('grades/add');
  27.     }
  28.  
  29.     public function edit($id)
  30.     {
  31.         helper(['url', 'form']);
  32.         $model = new GradeModel();
  33.         $data['grade'] = $model->find($id);
  34.        
  35.         return view('grades/edit', $data);
  36.     }
  37.  
  38.     public function delete($id)
  39.     {
  40.         $model = new GradeModel();
  41.         $model->delete($id);
  42.         session()->setFlashdata('status', 'Kelas berhasil terhapus');
  43.         return redirect()->to(base_url('grade'));
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement