add validation for masa input
This commit is contained in:
@@ -30,12 +30,12 @@ class FormOtherController extends Controller
|
||||
$this->checkAuthorization(auth()->user(), ['forms.other.view']);
|
||||
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
$forms = FormOthers::whereMonth('tanggal', date('m'))
|
||||
->whereYear('tanggal', date('Y'))
|
||||
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
|
||||
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE'))
|
||||
$startDate = date('Y-m-' . env('STARTING_DATE')); // Starting date from .env for the current month
|
||||
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); // Closing date for the next month
|
||||
|
||||
$forms = FormOthers::whereBetween('tanggal', [$startDate, $closingDateNextMonth])
|
||||
->orderBy('tanggal', 'desc')
|
||||
->with(['user', 'kategori'])
|
||||
->with('user')
|
||||
->get();
|
||||
|
||||
$availableBudget = null;
|
||||
@@ -124,6 +124,16 @@ class FormOtherController extends Controller
|
||||
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$currentDate = date('Y-m-d');
|
||||
$startDate = date('Y-m-' . env('STARTING_DATE'));
|
||||
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
|
||||
|
||||
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
|
||||
return response()->json([
|
||||
'error' => 'Current date is not within the valid range.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
$region = Region::where('id', $cabang->region_id)->first();
|
||||
$kategori = Kategori::where('id', $request->kategori_id)->first();
|
||||
|
||||
Reference in New Issue
Block a user