Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 19 |
| LeaveRequestController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 19 |
| index | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 19 |
|||
| <?php | |
| namespace App\Http\Controllers\Leave; | |
| use App\Http\Controllers\Controller; | |
| use Illuminate\Http\Request; | |
| use App\Models\Admin\Leave; | |
| use App\Models\Leave\ApplyLeave; | |
| use App\Models\Leave\RejectedLeave; | |
| use App\Helpers\GetShiftDetailHelper; | |
| use App\Models\Leave\LeaveEntitlement; | |
| use Illuminate\Database\Eloquent\SoftDeletes; | |
| use Illuminate\Support\Facades\DB; | |
| use App\Helpers\AttendanceHelper; | |
| class LeaveRequestController extends Controller | |
| { | |
| public function index(Request $request) | |
| { | |
| $title = '/Leave/Leave Requests'; | |
| $backUrl = route('home'); | |
| $Appliedleave = []; | |
| $userId = GetShiftDetailHelper::getMyReport(); | |
| // $Appliedleave= ApplyLeave::select('created_at', 'from_date', 'to_date', 'leave_length', 'reason', 'status') | |
| // ->whereIn('status',['Approve', 'Cancel', 'Pending','Reject']) | |
| // ->where('user_id', $userId); | |
| $appliedLeave = DB::table('apply_leaves') | |
| ->select(DB::raw("'apply_leave' as 'table_name'"), 'id', 'user_id', 'created_at', 'from_date', 'to_date','half_day_type', 'leave_length', 'reason', 'status') | |
| ->whereIn('status', ['Approve', 'Cancel', 'Pending', 'Reject']) | |
| ->where('user_id', $userId); | |
| $rejectedLeaves = DB::table('rejected_leaves') | |
| ->select(DB::raw("'rejected_leave' as 'table_name'"), 'id', 'user_id', 'created_at', 'from_date', 'to_date', 'half_day_type', 'leave_length', 'reason', 'status') | |
| ->where('status', 'Reject') | |
| ->where('user_id', $userId); | |
| $allLeaves = $appliedLeave->union($rejectedLeaves) | |
| ->orderBy('created_at', 'DESC') | |
| ->get(); | |
| // For returning attendance marking for home controller | |
| $val = AttendanceHelper::getAttendanceMarkValue(); | |
| $valTeam = AttendanceHelper::getAttendanceTeam($request); | |
| $valUser = AttendanceHelper::getAttendanceUser($request); | |
| return view('leave.userLeaveRequests', compact('title', 'allLeaves','val','valTeam','valUser')); | |
| } | |
| } |