LeaveApplication History Controller

For understanding, how the controller code, please refer to company controller

php artisan make:controller LeaveApplicationHistoryController

Replace the code with below

Note: Please use the copy button to copy the source code.

We need to include the following import statement(s)
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Auth;

class LeaveApplicationHistoryController extends Controller { // public function __construct() { $this->middleware('auth'); } public function index() { $this->authorize('history', LeaveApplication::class); $myApplications = DB::table('leave_applications') ->join('leave_types', 'leave_types.id', '=', 'leave_applications.leave_type_id') ->where('leave_applications.user_id', '=', Auth::id()) ->orderBy('leave_applications.created_at', 'asc') ->orderBy('leaveStatus', 'asc') ->select(['leave_applications.id', 'leaveStatus', 'leave_types.name as leaveType', 'leave_applications.created_at as createDate', 'startDate', 'endDate', 'fullDay', 'noOfDayDeduct']) ->paginate(20); session(['pageTitle' => 'Leave Application History']); session(['pageTitleIcon' => 'fa fa-th-list']); return view('leave-application-history.index', [ 'LeaveApplications' => $myApplications, ]); } }