HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/hrms-production/app/View/Components/LeaveManagementController.php
<?php

namespace App\Http\Controllers;
use App\Models\LeaveManagement;
use App\Models\EmployeeProfile;
use App\Models\LeaveTypes;
use App\Models\Leave;

use App\Library\UserLib;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
use Illuminate\Http\Request;

class LeaveManagementController extends Controller
{
    protected $userLib;
    protected $UserSessionId;
    public function __construct(UserLib $userLib)
    {
        $this->userLib = $userLib;
    }

    ### New Application
    public function createLeave(Request $request)
    {
        $LeaveId = $this->userLib->useridGenrator();
        $CreatedDate = date('Y-m-d H:i:s',time());
        $EmployeeId = $request->input('EmployeeId');
        $EmployeeCode = $request->input('EmployeeCode');
        $employeeDepartment = $request->input('employeeDepartment');
        $LeaveType = $request->input('LeaveType');
        $leaveStartDate = $request->input('leaveStartDate');
        $leaveEndDate = $request->input('leaveEndDate');
        $Remarks = $request->input('Remarks');
        $employeeDesignation = $request->input('employeeDesignation');
        $EmployeeName = $request->input('EmployeeName');        
        $LeaveDay = $request->input('LeaveDay');
        $NoOfDays = $request->input('NoOfDays');
         
         
        $data = array();
        $data['LeaveId'] = $LeaveId;
        $data['ApplicationNo'] = "LEAVE-" . time() . '-' . rand();
        $data['EmployeeId'] = $EmployeeId;
        $data['EmployeeCode'] = $EmployeeCode;      
        $data['EmployeeName'] = $EmployeeName;    
        $data['LeaveTypeId'] = $LeaveType;
        $data['StartDate'] = $leaveStartDate;
        $data['EndDate'] = $leaveEndDate;
        $data['Description'] = $Remarks;
        $data['LeaveName'] = $LeaveDay;
        $data['TotalLeave'] = $NoOfDays;      
        $data['Status'] = '1';
        $data['IsDeleted'] = '0';
        $data['LeaveStatus'] = '0';
        $data['Approved'] = '0';
        $data['Created_at'] = $CreatedDate;
        $data['Created_by'] = session('UserId');
        $data['Updated_at'] = $CreatedDate;
        $data['Updated_by'] = session('UserId');
        $data['UserName'] = session('UserId');
        $data['AssignTo'] = session('UserId');
        $Leave = Leave::insert($data);
        if ($Leave) {
            return response()->json('success');
        } else {
            return response()->json('failed');
        }
    }

    public function newApplication()
    {
        $AllEmployee = EmployeeProfile::select('tbl_employees.*', 'tbl_department.DepartmentName as DepartmentName', 'tbl_designation.DesignationName as DesignationName')
        ->leftJoin('tbl_department', 'tbl_employees.DepartmentId', '=', 'tbl_department.DepartmentId')
        ->leftJoin('tbl_designation', 'tbl_employees.DesignationId', '=', 'tbl_designation.DesignationId')
        ->where('tbl_employees.IsDeleted', '=', '0')
        ->orderBy('tbl_employees.id', 'desc')
        ->get();

        $LeaveTypes = LeaveTypes::select('*')
        ->where('IsDeleted', '=', '0')
        ->where('Status', '=', '1')
        ->orderBy('LeaveTypeName', 'asc')
        ->get();

        return view('admin.LeaveManagement.new-application', ['EmployeesData' => $AllEmployee, 'LeaveTypes' => $LeaveTypes]);
    }

    ### All Application
    public function allApplication()
    {
        $Leaves = Leave::select('tbl_leave.*','tbl_leave_type.LeaveTypeName')
        ->leftJoin('tbl_leave_type', 'tbl_leave.LeaveTypeId', '=', 'tbl_leave_type.LeaveTypeId')
        ->where('tbl_leave.IsDeleted', '=', '0')
        ->where('tbl_leave.Status', '=', '1')
        ->orderBy('tbl_leave.Created_at', 'desc')
        ->get();

        return view('admin.LeaveManagement.all-application', ['Leaves' => $Leaves]);
    }

    ### Leave Category
    public function leaveCategory()
    {
        return view('admin.LeaveManagement.leave-category');
    }

    ### Leave Type
    public function leaveType()
    {
        return view('admin.LeaveManagement.leave-type');
    }

    ### Holiday List
    public function empLeaves()
    {
        return view('admin.LeaveManagement.employee-leaves');
    }

    ### Holiday List
    public function holidayList()
    {
        return view('admin.LeaveManagement.holiday-list');
    }

    ### View Application
    public function viewApplication()
    {
        return view('admin.LeaveManagement.view-application');
    }
}