Crud Ci 4

  1. Need to add migration for make CRUD
    • Migration step using CLI
      • Run command php spark make:migration
      • After that need to enter class name migration
      • Will generate file on app/database/migrations
      • Then run php spark migrate
  2. After migration proceed to generate controllers file
    • Controller step using CLI
      • Run command php spark make:controller
        • In CRUD scenario we can use –restful
      • After that need to enter class name controller
      • Then controllers file will be generated with function default Restful function
  3. Then generate model
    • Model step using CLI
      • Run command php spark make:model
      • After that need to enter class name model
      • Then model will be generated like this
      • Setup allowed fields
  4. Then we will start with listing using function index
    • add code for query data using model
    • add index.php in folder students
    • add code for view listing in index.php
    • then go to app/config/routes.php setup routes for listing
  5. Next we go to create
    • In function new load view for create
    • In view file add form code
    • Then add code at function create for insert data
    • Setup routes like this
  6. After create we continue with Update
    • Add code at function edit with view file

    • Then we add function update
    • Setup routes
  7. Lastly, we make function delete
    • Just add process for delete at function delete
    • Setup routes
  8. Settle !!!

Note: Goodluck on your CRUD using CI4

Leave a comment

Your email address will not be published. Required fields are marked *