Summary
Highlights
The video introduces the 13th meeting of the Web-Based Programming course, focusing on PHP frameworks CodeIgniter and Laravel. The main objective is to understand and implement CRUD (Create, Read, Update, and Delete) operations using the Model-View-Controller (MVC) concept. The instructor, Muhammad Widianto, outlines the learning goals: comprehending CRUD concepts in frameworks and implementing them with CodeIgniter or Laravel. The session builds upon previous lessons, including environment setup, migrations, and seeders, and transitions into SCR (Source Code Review).
The first section of the practical implementation demonstrates CRUD with CodeIgniter. It starts by running a CodeIgniter project and reviewing existing routes. The instructor then guides through creating a new 'product' module. This involves generating a migration for the 'products' table, defining its columns (ID, code, name, stock), and running the migration. Subsequently, a 'ProductModel' is created to interact with the database, and a 'ProductController' is developed. The 'index' function in the controller is set up to display a list of products, and a 'create' function and corresponding view are developed to add new products to the database, including validation and saving data.
Continuing with CodeIgniter, the video demonstrates how to display existing product data. The 'index' view is enhanced to loop through product data retrieved from the 'ProductModel' and display it in a table format. For the 'Update' operation, an 'edit' function and view are created, allowing users to modify existing product details. This involves fetching product data by ID, populating the edit form, and submitting changes to an 'update' function in the controller. Finally, the 'Delete' operation is implemented with a 'destroy' function, which removes a product from the database based on its ID. The video shows successful creation, reading, updating, and deleting of product records.
The tutorial then shifts to Laravel. It begins by creating a new Laravel project using Composer. The instructor emphasizes checking PHP and Composer versions for compatibility. After project creation, the process involves configuring the '.env' file, specifically setting up the database connection details (MySQL/MariaDB username, password, and database name). A new database named 'DB Laravel' is created, and 'php artisan key:generate' is run to generate an application key. The default Laravel migrations are then executed to create essential tables like 'users' and 'sessions'. This ensures the initial Laravel setup is functional.
The Laravel section continues with creating a 'products' table migration, similar to CodeIgniter, defining columns like code, name, and stock, and running the migration. A 'Product' model is then generated, and its 'fillable' properties (code, name, stock) are defined. The video highlights the difference in routing between CodeIgniter (roots.php) and Laravel (web.php). A 'ProductController' is created, and an 'index' function is implemented to fetch all products using the 'Product' model and pass them to an 'index.blade.php' view. A 'create' function and its corresponding 'create.blade.php' view are also set up to facilitate adding new products, including form validation and saving data.
The final part of the Laravel CRUD implementation covers updating and deleting products. An 'edit' function in the 'ProductController' is created to retrieve a specific product by ID and display its details in an 'edit.blade.php' view. This form allows users to modify product information. The 'update' function then handles saving these changes to the database. For deleting, a 'destroy' function is implemented to remove products. The video demonstrates the full CRUD cycle with Laravel. Lastly, the instructor briefly shows how to integrate Tailwind CSS into the Laravel project to improve the visual appeal of the forms and tables, transforming basic HTML elements into more polished UI components.
The video concludes by assigning a task to students: create a summarized video (minimum 5 minutes) of the 13th meeting, focusing on practicing CRUD implementation with both CodeIgniter and Laravel, and upload it to YouTube. The link to this resume video should be submitted on Google Classroom within one week or before the next meeting. This assignment aims to reinforce the concepts and practical skills learned during the session.