Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
simpmw
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alfiro Pratama
simpmw
Commits
575363c3
Commit
575363c3
authored
Mar 11, 2026
by
Alfiro Pratama
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix preg match usulan dana
parent
c495e6f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
2 deletions
+51
-2
app/Http/Controllers/Mahasiswa/ProposalController.php
+51
-2
No files found.
app/Http/Controllers/Mahasiswa/ProposalController.php
View file @
575363c3
...
@@ -75,7 +75,7 @@ class ProposalController extends Controller
...
@@ -75,7 +75,7 @@ class ProposalController extends Controller
->
where
(
'periode_id'
,
$periode
->
periode_id
)
->
where
(
'periode_id'
,
$periode
->
periode_id
)
->
where
(
'status'
,
'1'
)
->
where
(
'status'
,
'1'
)
->
first
();
->
first
();
// dd($kelompok, $periode);
$cekproposal
=
Proposal
::
where
(
'created_user'
,
auth
()
->
user
()
->
id
)
$cekproposal
=
Proposal
::
where
(
'created_user'
,
auth
()
->
user
()
->
id
)
->
where
(
'periode_id'
,
$periode
->
periode_id
)
->
where
(
'periode_id'
,
$periode
->
periode_id
)
->
first
();
->
first
();
...
@@ -122,6 +122,55 @@ class ProposalController extends Controller
...
@@ -122,6 +122,55 @@ class ProposalController extends Controller
//
//
$proposal
=
$request
->
except
(
'_token'
);
$proposal
=
$request
->
except
(
'_token'
);
// Normalisasi usulan_dana agar menerima berbagai format:
// - "5.000.000,00" -> 5000000
// - "5,000,000.00" -> 5000000
// - "5,000,000,00" -> 5000000
// - "5000000" -> 5000000
//
// Aturan:
// - Jika ada pemisah desimal (',' atau '.') di bagian paling kanan dan diikuti 1-2 digit,
// maka bagian setelah pemisah tersebut dibuang (anggap desimal).
// - Semua pemisah ribuan (',' atau '.') di bagian integer dibuang.
$rawUsulan
=
(
string
)
(
$proposal
[
'usulan_dana'
]
??
''
);
$rawUsulan
=
trim
(
$rawUsulan
);
if
(
$rawUsulan
===
''
)
{
$usulanDana
=
0
;
}
else
{
// Buang spasi
$s
=
preg_replace
(
'/\s+/'
,
''
,
$rawUsulan
);
// Cari separator paling kanan (',' atau '.')
$lastComma
=
strrpos
(
$s
,
','
);
$lastDot
=
strrpos
(
$s
,
'.'
);
$lastSepPos
=
-
1
;
$lastSepChar
=
null
;
if
(
$lastComma
!==
false
&&
$lastComma
>
$lastSepPos
)
{
$lastSepPos
=
$lastComma
;
$lastSepChar
=
','
;
}
if
(
$lastDot
!==
false
&&
$lastDot
>
$lastSepPos
)
{
$lastSepPos
=
$lastDot
;
$lastSepChar
=
'.'
;
}
$intPart
=
$s
;
if
(
$lastSepPos
!==
-
1
)
{
$after
=
substr
(
$s
,
$lastSepPos
+
1
);
// Jika setelah separator isinya 1-2 digit saja, anggap itu desimal dan buang
if
(
$after
!==
''
&&
preg_match
(
'/^\d{1,2}$/'
,
$after
))
{
$intPart
=
substr
(
$s
,
0
,
$lastSepPos
);
}
}
// Hapus semua pemisah ribuan yang tersisa, lalu ambil digit saja
$intPart
=
str_replace
([
','
,
'.'
],
''
,
$intPart
);
$digits
=
preg_replace
(
'/\D+/'
,
''
,
$intPart
);
$usulanDana
=
$digits
===
''
?
0
:
(
int
)
$digits
;
}
$this
->
validate
(
$request
,
$this
->
validate
(
$request
,
[
[
'file'
=>
'required|mimes:pdf|max:5000'
,
'file'
=>
'required|mimes:pdf|max:5000'
,
...
@@ -150,7 +199,7 @@ class ProposalController extends Controller
...
@@ -150,7 +199,7 @@ class ProposalController extends Controller
'judul'
=>
$proposal
[
'judul'
],
'judul'
=>
$proposal
[
'judul'
],
'status'
=>
'0'
,
'status'
=>
'0'
,
'upload_dokumen'
=>
$file_nama
,
'upload_dokumen'
=>
$file_nama
,
'usulan_dana'
=>
$
proposal
[
'usulan_dana'
]
,
'usulan_dana'
=>
$
usulanDana
,
'date_upload'
=>
now
(),
'date_upload'
=>
now
(),
'created_user'
=>
Auth
::
user
()
->
id
'created_user'
=>
Auth
::
user
()
->
id
]);
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment