Admin dashboard in Laravel | HR Management System

Admin dashboard in Laravel | HR Management System

               Admin dashboard in Laravel  | HR Management System

An HRMS, or human resources management system, is a suite of software applications used to manage human resources and related processes throughout the employee lifecycle. An HRMS enables a company to fully understand its workforce while staying compliant with changing tax laws and labor regulations.

HR leaders and staff are the primary users, given that they run day-to-day workforce operations and are responsible for compliance and performance reporting. However, HR isn’t the only department that benefits. Companies can empower managers and employees with self-service for common tasks—an important selling point for younger hires. Executives can use an HRMS to generate data on workforce trends and their business implications.




Step 1: Install Laravel 8

step: Install UI

Note:

composer require laravel/ui
php artisan ui vue --auth

First, install a new Laravel app just by running the below command in your terminal.

composer create-project --prefer-dist laravel/laravel hr_ms_laravel8


Step 2: Update Your Database Credentials

After that update your database credentials in your .env file which is located in your project root.

1. connection databases

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_db
DB_USERNAME=root
DB_PASSWORD=#your database password
2. for send mail when fogot password

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your email
MAIL_PASSWORD='your password email'
MAIL_ENCRYPTION=tls

Step 3: Make Migration

After adding the migration file now run the migrate command.

php artisan migrate

Step 4: Add in Home Page

Add the below code in your home.blade.php file.

Resources/Views/dashboard/dashbiard.blade.php

@extends('layouts.master')
{{--
@section('menu')
@extends('sidebar.dashboard')
@endsection --}}
@section('content')
<!-- Sidebar -->
<div class="sidebar" id="sidebar">
<div class="sidebar-inner slimscroll">
<div id="sidebar-menu" class="sidebar-menu">
<ul>
<li class="menu-title">
<span>Main</span>
</li>
<li class="submenu">
<a href="#"><i class="la la-dashboard"></i>
<span> Dashboard</span> <span class="menu-arrow"></span>
</a>
<ul style="display: none;">
<li><a class="active" href="{{ route('home') }}">Admin Dashboard</a></li>
<li><a href="{{ route('em/dashboard') }}">Employee Dashboard</a></li>
</ul>
</li>
<li class="menu-title"> <span>Employees</span> </li>
<li class="submenu">
<a href="#" class="noti-dot">
<i class="la la-user"></i> <span> Employees</span> <span class="menu-arrow"></span>
</a>
<ul style="display: none;">
<li><a href="employees.html">All Employees</a></li>
<li><a href="holidays.html">Holidays</a></li>
<li><a href="leaves.html">Leaves (Admin)
<span class="badge badge-pill bg-primary float-right">1</span></a>
</li>
<li><a href="leaves-employee.html">Leaves (Employee)</a></li>
<li><a href="leave-settings.html">Leave Settings</a></li>
<li><a href="attendance.html">Attendance (Admin)</a></li>
<li><a href="attendance-employee.html">Attendance (Employee)</a></li>
<li><a href="departments.html">Departments</a></li>
<li><a href="designations.html">Designations</a></li>
<li><a href="timesheet.html">Timesheet</a></li>
<li><a href="shift-scheduling.html">Shift & Schedule</a></li>
<li><a href="overtime.html">Overtime</a></li>
</ul>
</li>
<li class="menu-title"> <span>Pages</span> </li>
<li class="submenu"> <a href="#"><i class="la la-user"></i>
<span> Profile </span> <span class="menu-arrow"></span></a>
<ul style="display: none;">
<li><a href="profile.html"> Employee Profile </a></li>
<li><a href="client-profile.html"> Client Profile </a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
@endsection@extends('layouts.master')
@section('menu')
@extends('sidebar.dashboard')
@endsection --}}
@section('content')
@endsection

Step5: Add Button in Register Page

Add the below code in your register.blade.php file.

Resources/Views/passwords/Auth/register.blade.php

@extends('layouts.app') @section('content') <div class="main-wrapper"> <div class="account-content"> <a href="job-list.html" class="btn btn-primary apply-btn">Apply Job</a> <div class="container"> <!-- Account Logo --> <div class="account-logo"> <a href="index.html"><img src="{{ URL::to('assets/img/logo2.png') }}" alt="SoengSouy"></a> </div> <!-- /Account Logo --> <div class="account-box"> <div class="account-wrapper"> <h3 class="account-title">Register</h3> <p class="account-subtitle">Access to our dashboard</p> <!-- Account Form --> <form method="POST" action="{{ route('register') }}"> @csrf <div class="form-group"> <label>Username</label> <input type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" placeholder="Enter Your Name"> @error('name') <span class="invalid-feedback" role="alert"> <strong>{{ $message }}</strong> </span> @enderror </div> <div class="form-group"> <label>Email</label> <input type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" placeholder="Enter Your Email"> @error('email') <span class="invalid-feedback" role="alert"> <strong>{{ $message }}</strong> </span> @enderror </div> {{-- insert defaults --}} <input type="hidden" class="image" name="image" value="photo_defaults.jpg"> <div class="form-group"> <label class="col-form-label">Role Name</label> <select class="select @error('role_name') is-invalid @enderror" name="role_name" id="role_name"> <option selected disabled>Select Role Name</option> <option value="Admin">Admin</option> <option value="Super Admin">Super Admin</option> <option value="Normal User">Normal User</option> </select> @error('role_name') <span class="invalid-feedback" role="alert"> <strong>{{ $message }}</strong> </span> @enderror </div> <div class="form-group"> <label>Password</label> <input type="password" class="form-control @error('password') is-invalid @enderror" name="password" placeholder="Enter Password"> @error('password') <span class="invalid-feedback" role="alert"> <strong>{{ $message }}</strong> </span> @enderror </div> <div class="form-group"> <label><strong>Repeat Password</strong></label> <input type="password" class="form-control" name="password_confirmation" placeholder="Choose Repeat Password"> </div> <div class="form-group text-center"> <button class="btn btn-primary account-btn" type="submit">Register</button> </div> <div class="account-footer"> <p>Already have an account? <a href="{{ route('login') }}">Login</a></p> </div> </form> <!-- /Account Form --> </div> </div> </div> </div> </div> @endsection

Step 6: Create RegisterController

php artisan make:controller RegisterController

<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\User; use Brian2694\Toastr\Facades\Toastr; use Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rules\Password; class RegisterController extends Controller { public function register() { return view('auth.register'); } public function storeUser(Request $request) { $request->validate([ 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'role_name' => 'required|string|max:255', 'password' => 'required|string|min:8|confirmed', 'password_confirmation' => 'required', ]); User::create([ 'name' => $request->name, 'avatar' => $request->image, 'email' => $request->email, 'role_name' => $request->role_name, 'password' => Hash::make($request->password), ]); Toastr::success('Create new account successfully :)','Success'); return redirect('login'); } }

Step 7: Create LoginController

php artisan make:controller LoginController

<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; use Auth; use DB; use App\Models\User; use Carbon\Carbon; use Session; use Brian2694\Toastr\Facades\Toastr; class LoginController extends Controller { /* |-------------------------------------------------------------------------- | Login Controller |-------------------------------------------------------------------------- | | This controller handles authenticating users for the application and | redirecting them to your home screen. The controller uses a trait | to conveniently provide its functionality to your applications. | */ use AuthenticatesUsers; /** * Where to redirect users after login. * * @var string */ protected $redirectTo = RouteServiceProvider::HOME; /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('guest')->except([ 'logout', 'locked', 'unlock' ]); } public function login() { return view('auth.login'); } public function authenticate(Request $request) { $request->validate([ 'email' => 'required|string|email', 'password' => 'required|string', ]); $email = $request->email; $password = $request->password; $dt = Carbon::now(); $todayDate = $dt->toDayDateTimeString(); $activityLog = [ 'name' => $email, 'email' => $email, 'description' => 'has log in', 'date_time' => $todayDate, ]; if (Auth::attempt(['email'=>$email,'password'=>$password,'status'=>'Active'])) { DB::table('activity_logs')->insert($activityLog); Toastr::success('Login successfully :)','Success'); return redirect()->intended('home'); }elseif (Auth::attempt(['email'=>$email,'password'=>$password,'status'=> null])) { DB::table('activity_logs')->insert($activityLog); Toastr::success('Login successfully :)','Success'); return redirect()->intended('home'); } else{ Toastr::error('fail, WRONG USERNAME OR PASSWORD :)','Error'); return redirect('login'); } } public function logout() { $user = Auth::User(); Session::put('user', $user); $user=Session::get('user'); $name = $user->name; $email = $user->email; $dt = Carbon::now(); $todayDate = $dt->toDayDateTimeString(); $activityLog = [ 'name' => $name, 'email' => $email, 'description' => 'has logged out', 'date_time' => $todayDate, ]; DB::table('activity_logs')->insert($activityLog); Auth::logout(); Toastr::success('Logout successfully :)','Success'); return redirect('login'); } }


Step 8: Add Button in Login Page

Add the below code in your login.blade.php file.

Resources/Views/passwords/Auth/login.blade.php

@extends('layouts.app')
@section('content')
    <div class="main-wrapper">
        <div class="account-content">
            <a href="job-list.html" class="btn btn-primary apply-btn">Apply Job</a>
            <div class="container">
                <!-- Account Logo -->
                <div class="account-logo">
                    <a href="index.html"><img src="{{ URL::to('assets/img/logo2.png') }}" alt="Soeng Souy"></a>
                </div>
                {{-- message --}}
                {!! Toastr::message() !!}
                <!-- /Account Logo -->
                <div class="account-box">
                    <div class="account-wrapper">
                        <h3 class="account-title">Login</h3>
                        <p class="account-subtitle">Access to our dashboard</p>
                        <!-- Account Form -->
                        <form method="POST" action="{{ route('login') }}">
                            @csrf
                            <div class="form-group">
                                <label>Email Address</label>
                                <input type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" placeholder="Enter email">
                                @error('email')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col">
                                        <label>Password</label>
                                    </div>
                                </div>
                                <input type="password" class="form-control @error('password') is-invalid @enderror" name="password" placeholder="Enter Password">
                                @error('password')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col">
                                        <label></label>
                                    </div>
                                    <div class="col-auto">
                                        <a class="text-muted" href="{{ route('forget-password') }}">
                                            Forgot password?
                                        </a>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group text-center">
                                <button class="btn btn-primary account-btn" type="submit">Login</button>
                            </div>
                            <div class="account-footer">
                                <p>Don't have an account yet? <a href="{{ route('register') }}">Register</a></p>
                            </div>
                        </form>
                        <!-- /Account Form -->
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

Step 9: Add Routes

In this step we create routes for Facebook login, add two routes in your web.php file.

app/routes/web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PhotosController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\ResetPasswordController;
use App\Http\Controllers\FormController;
use App\Http\Controllers\UserManagementController;
use App\Http\Controllers\LockScreen;
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
| Web Routes
| Here is where you can register web routes for your application. These
|
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () { return view('auth.login'); }); Route::group(['middleware'=>'auth'],function() { Route::get('home',function() { return view('home'); }); Route::get('home',function() { return view('home'); }); }); Auth::routes(); // ----------------------------- main dashboard ------------------------------// Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); Route::get('em/dashboard', [App\Http\Controllers\HomeController::class, 'emDashboard'])->name('em/dashboard'); // -----------------------------login----------------------------------------// Route::get('/login', [App\Http\Controllers\Auth\LoginController::class, 'login'])->name('login'); Route::post('/login', [App\Http\Controllers\Auth\LoginController::class, 'authenticate']); Route::get('/logout', [App\Http\Controllers\Auth\LoginController::class, 'logout'])->name('logout'); // ----------------------------- lock screen --------------------------------// Route::get('lock_screen', [App\Http\Controllers\LockScreen::class, 'lockScreen'])->middleware('auth')->name('lock_screen'); Route::post('unlock', [App\Http\Controllers\LockScreen::class, 'unlock'])->name('unlock'); // ------------------------------ register ---------------------------------// Route::get('/register', [App\Http\Controllers\Auth\RegisterController::class, 'register'])->name('register'); Route::post('/register', [App\Http\Controllers\Auth\RegisterController::class, 'storeUser'])->name('register'); // ----------------------------- forget password ----------------------------// Route::get('forget-password', [App\Http\Controllers\Auth\ForgotPasswordController::class, 'getEmail'])->name('forget-password'); Route::post('forget-password', [App\Http\Controllers\Auth\ForgotPasswordController::class, 'postEmail'])->name('forget-password'); // ----------------------------- reset password -----------------------------// Route::get('reset-password/{token}', [App\Http\Controllers\Auth\ResetPasswordController::class, 'getPassword']); Route::post('reset-password', [App\Http\Controllers\Auth\ResetPasswordController::class, 'updatePassword']); // ----------------------------- user profile ------------------------------// Route::get('profile_user', [App\Http\Controllers\UserManagementController::class, 'profile'])->name('profile_user'); Route::post('profile_user/store', [App\Http\Controllers\UserManagementController::class, 'profileStore'])->name('profile_user/store'); // ----------------------------- user userManagement -----------------------// Route::get('userManagement', [App\Http\Controllers\UserManagementController::class, 'index'])->middleware('auth')->name('userManagement'); Route::get('user/add/new', [App\Http\Controllers\UserManagementController::class, 'addNewUser'])->middleware('auth')->name('user/add/new'); Route::post('user/add/save', [App\Http\Controllers\UserManagementController::class, 'addNewUserSave'])->name('user/add/save'); Route::get('view/detail/{id}', [App\Http\Controllers\UserManagementController::class, 'viewDetail'])->middleware('auth'); Route::post('update', [App\Http\Controllers\UserManagementController::class, 'update'])->name('update'); Route::get('delete_user/{id}', [App\Http\Controllers\UserManagementController::class, 'delete'])->middleware('auth'); Route::get('activity/log', [App\Http\Controllers\UserManagementController::class, 'activityLog'])->middleware('auth')->name('activity/log'); Route::get('activity/login/logout', [App\Http\Controllers\UserManagementController::class, 'activityLogInLogOut'])->middleware('auth')->name('activity/login/logout'); // ----------------------------- form change password ------------------------------// Route::get('change/password', [App\Http\Controllers\UserManagementController::class, 'changePasswordView'])->middleware('auth')->name('change/password');
Route::post('change/password/db', [App\Http\Controllers\UserManagementController::class, 'changePasswordDB'])->name('change/password/db');

Step 10: Run Development Server

After successfully updating all run the development server just adds the below command in the terminal.

php artisan serve

After this go to the browser and check using the login page.

http://localhost/hr_ms_laravel8/public/

Souy Soeng

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

7 Comments

  1. can we post this online if we clone it ?

    ReplyDelete
  2. can you share this front End Template ( HTML & CSS - bootstrap ) without Laravel ? i need to use it to learn Django? <3

    ReplyDelete
  3. i got it .. thank you <3 https://gitlab.com/SoengSouy/hrsm_admin_dashboard

    ReplyDelete
  4. Replies
    1. SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE')

      Delete
Previous Post Next Post
close