04 - Membuat Proses Login Untuk User
Summary
TLDRIn this tutorial, the presenter walks through building a GPS-based attendance application with a selfie photo feature. The focus is on creating a login system for employees and administrators using Laravel. Key steps include setting up the database, creating models for `karyawan` (employee) and `user`, configuring authentication guards, and implementing a login process with encrypted passwords. The tutorial also covers redirecting users to a dashboard after successful login. This video is a practical guide to handling user authentication and database management in a Laravel project.
Takeaways
- π The tutorial focuses on building an attendance app with GPS and selfie photo functionality.
- π The project starts by setting up a database with two main tables: `karyawan` (employees) and `presensi` (attendance).
- π A third table, `user`, is added for administrator login, and Laravelβs built-in authentication system is used.
- π The `karyawan` table will be used for employee login, while the `user` table will be used for admin login.
- π The database connection is set up in Laravel, with the project database named 'presensi GPS'.
- π The tutorial demonstrates how to use Laravel migrations to create tables, including removing unnecessary tables.
- π A custom model is created for `Karyawan`, and its attributes are set to match the database structure (NIK, full name, position, etc.).
- π Laravel's `auth.php` configuration is modified to include custom guards for differentiating between employee and admin logins.
- π The `outController` is created to handle the login process, including receiving POST data and checking user credentials.
- π The tutorial explains how to use `Hash` to encrypt passwords for secure login functionality.
- π After a successful login, employees are redirected to a dashboard page. The redirect was initially broken but fixed by adding the `return` statement.
Q & A
What is the main goal of the video tutorial?
-The main goal of the tutorial is to guide viewers through creating an employee attendance application using GPS and selfie photos. The tutorial focuses on setting up the database and implementing the login system for employees using two tables: 'karyawan' and 'user'.
What is the purpose of the 'karyawan' table in the database?
-The 'karyawan' table is used to store employee data, including personal details and login credentials. It is specifically designed for the employee login system, where employees will authenticate using their NIK and password.
Why is a separate 'user' table needed in the application?
-The 'user' table is needed to handle the login system for administrators. While the 'karyawan' table manages employee login, the 'user' table is used for administrators to access the administrative pages of the application.
What is the purpose of the 'guard' in Laravel authentication configuration?
-In Laravel, the 'guard' is used to define different authentication methods for different types of users. In this project, two guards are defined: one for the 'karyawan' (employee) and one for the 'user' (administrator) to handle separate authentication processes.
What does the 'artisan migrate' command do in the Laravel project?
-'php artisan migrate' is a command used to create or update the database tables according to the migrations defined in the project. This command will automatically generate the necessary tables such as 'karyawan', 'presensi', and 'user' based on the migration files.
Why was the 'user' table migration adjusted in the project?
-The 'user' table migration was adjusted to only include the necessary table for administrator login, and unnecessary migrations like password resets and personal access tokens were removed to simplify the setup.
How is the model for 'karyawan' set up to match the database table?
-The model for 'karyawan' is set up to match the database table by specifying the table name explicitly, as Laravel uses a default plural naming convention. In this case, the table is named 'karyawan' instead of the plural form 'karyawans', and the model is instructed to use the correct table and primary key (NIK).
What changes were made to the login form in the Blade view?
-The login form was modified to accept 'NIK' (employee ID) as the username instead of the default 'email'. Additionally, the form fields were updated to reflect the 'NIK' and 'password' fields, and the form action was set to the 'proses login' route.
How is the login functionality for employees (karyawan) implemented?
-The login functionality for employees is implemented by comparing the 'NIK' and 'password' entered in the form with the records in the 'karyawan' table. If the credentials match, the employee is successfully logged in; otherwise, a failure message is displayed.
What does the 'proses login' method in the OutController do?
-The 'proses login' method in the OutController processes the data submitted by the login form. It retrieves the 'NIK' and 'password' from the request and checks the credentials against the 'karyawan' table. If the authentication is successful, it redirects the user to the dashboard, otherwise, it shows a login failure message.
Outlines

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowMindmap

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowKeywords

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowHighlights

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowTranscripts

This section is available to paid users only. Please upgrade to access this part.
Upgrade NowBrowse More Related Video
5.0 / 5 (0 votes)





