Fix: upload bulk in column date, and fix template
This commit is contained in:
@@ -74,6 +74,7 @@ class SpatialPlanningController extends Controller
|
||||
*/
|
||||
public function importFromFile(Request $request)
|
||||
{
|
||||
info($request);
|
||||
//validasi file
|
||||
$validator = Validator::make($request->all(), [
|
||||
'file' => 'required|mimes:xlsx, xls|max:10240'
|
||||
|
||||
@@ -38,15 +38,10 @@ class SpatialPlanningImport implements ToCollection
|
||||
}
|
||||
|
||||
foreach ($rows->skip(1) as $row) {
|
||||
$dateValue = $row[7];
|
||||
|
||||
try {
|
||||
// Coba parsing tanggal secara otomatis
|
||||
$parsedDate = Carbon::parse($dateValue)->format('Y-m-d H:i:s');
|
||||
} catch (\Exception $e) {
|
||||
// Jika gagal parsing, atur nilai default atau null
|
||||
$parsedDate = null;
|
||||
}
|
||||
$dateValue = trim($row[7]);
|
||||
info($dateValue);
|
||||
$parsedDate = Carbon::createFromFormat('Y-m-d', $dateValue)->format('Y-m-d');
|
||||
info($parsedDate);
|
||||
|
||||
$dataToInsert[] = [
|
||||
'name'=>$row[1],
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user