changed bukti 2 & 3 to accept all file
This commit is contained in:
@@ -20,6 +20,7 @@ use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
use App\Helpers\AuditTrailHelper;
|
||||
use App\Rules\FileType;
|
||||
|
||||
class FormEntertainmentPresentationController extends Controller
|
||||
{
|
||||
@@ -84,8 +85,8 @@ class FormEntertainmentPresentationController extends Controller
|
||||
'alamat' => 'required',
|
||||
'nik_or_npwp' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
@@ -189,8 +190,8 @@ class FormEntertainmentPresentationController extends Controller
|
||||
'alamat' => 'required',
|
||||
'nik_or_npwp' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$form = FormEntertaimentPresentation::findOrfail($id);
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
use App\Helpers\AuditTrailHelper;
|
||||
use App\Rules\FileType;
|
||||
|
||||
class FormMeetingSeminarController extends Controller
|
||||
{
|
||||
@@ -80,8 +81,8 @@ class FormMeetingSeminarController extends Controller
|
||||
'transport_ankot' => 'required',
|
||||
'hotel' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
@@ -178,8 +179,8 @@ class FormMeetingSeminarController extends Controller
|
||||
'transport_ankot' => 'required',
|
||||
'hotel' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$form = FormMeetingSeminar::findOrfail($id);
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
use App\Helpers\AuditTrailHelper;
|
||||
use App\Rules\FileType;
|
||||
|
||||
class FormOtherController extends Controller
|
||||
{
|
||||
@@ -83,8 +84,8 @@ class FormOtherController extends Controller
|
||||
'keterangan' => 'required',
|
||||
'total' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
@@ -183,8 +184,8 @@ class FormOtherController extends Controller
|
||||
'keterangan' => 'required',
|
||||
'total' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$form = FormOthers::findOrfail($id);
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
use App\Helpers\AuditTrailHelper;
|
||||
use App\Rules\FileType;
|
||||
|
||||
class FormUpCountryController extends Controller
|
||||
{
|
||||
@@ -86,8 +87,8 @@ class FormUpCountryController extends Controller
|
||||
'transport_dalkot' => 'required',
|
||||
'transport_ankot' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
@@ -195,8 +196,8 @@ class FormUpCountryController extends Controller
|
||||
'transport_ankot' => 'required',
|
||||
'hotel' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Mail\ExpenseRejected;
|
||||
use App\Mail\FinalApprove;
|
||||
use App\Helpers\WhatsappHelper;
|
||||
use App\Helpers\AuditTrailHelper;
|
||||
use App\Rules\FileType;
|
||||
|
||||
class FormVehicleController extends Controller
|
||||
{
|
||||
@@ -84,8 +85,8 @@ class FormVehicleController extends Controller
|
||||
'nopol' => 'required',
|
||||
'keterangan' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
|
||||
@@ -189,8 +190,8 @@ class FormVehicleController extends Controller
|
||||
'nopol' => 'required',
|
||||
'keterangan' => 'required',
|
||||
'bukti1' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg,heic,heif|max:51200',
|
||||
'bukti2' => 'nullable|file|mimes:xlsx,xls,csv',
|
||||
'bukti3' => 'nullable|file|mimes:pdf',
|
||||
'bukti2' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
'bukti3' => ['nullable', 'file', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
|
||||
]);
|
||||
|
||||
$form = FormVehicleRunningCost::findOrfail($id);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class FileType implements ValidationRule
|
||||
{
|
||||
protected array $disallowedExtensions;
|
||||
|
||||
/**
|
||||
* Constructor to initialize disallowed file extensions.
|
||||
*
|
||||
* @param array $disallowedExtensions
|
||||
*/
|
||||
public function __construct(array $disallowedExtensions)
|
||||
{
|
||||
$this->disallowedExtensions = $disallowedExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if ($value && $value->isValid()) {
|
||||
// Get the file extension
|
||||
$extension = strtolower($value->getClientOriginalExtension());
|
||||
|
||||
// Check if the extension is in the disallowed list
|
||||
if (in_array($extension, $this->disallowedExtensions)) {
|
||||
$fail("The file type '{$extension}' is not allowed.");
|
||||
}
|
||||
} else {
|
||||
$fail("The uploaded file for '{$attribute}' is invalid.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user