update addon HRM
Some checks failed
Some checks failed
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\HrmAddon\App\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Modules\HrmAddon\App\Models\Leave;
|
||||
|
||||
class LeaveReportController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data = Leave::with(['employee:id,name', 'branch:id,name', 'leave_type:id,name', 'department:id,name'])
|
||||
->where('business_id', auth()->user()->business_id)
|
||||
->when($request->employee_id, function ($query) use ($request) {
|
||||
$query->where('employee_id', $request->employee_id);
|
||||
})
|
||||
->when($request->month, function ($query) use ($request) {
|
||||
$month = strtolower($request->month);
|
||||
$query->whereRaw("LOWER(month) = ?", [$month]);
|
||||
})
|
||||
->latest()
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Data fetched successfully.'),
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user