Skip to content

Commit 35d58f5

Browse files
author
A. Van Driessche
authored
Merge pull request #2317 from codeeu/dev
Dev
2 parents 2235e3e + 4e8822b commit 35d58f5

3 files changed

Lines changed: 53 additions & 11 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace App\Console\Commands\excel;
4+
5+
use App\Imports\CoderDojoEventsImport;
6+
use Illuminate\Console\Command;
7+
use Illuminate\Support\Facades\Log;
8+
use Maatwebsite\Excel\Facades\Excel;
9+
10+
class CoderDojoEvents extends Command
11+
{
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'excel:coderdojo';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Coder Dojo 2024 From Excel File';
25+
26+
/**
27+
* Create a new command instance.
28+
*
29+
* @return void
30+
*/
31+
public function __construct()
32+
{
33+
parent::__construct();
34+
}
35+
36+
/**
37+
* Execute the console command.
38+
*/
39+
public function handle(): void
40+
{
41+
Log::info('Loading Coder Dojo Excel File');
42+
43+
Excel::import(
44+
new CoderDojoEventsImport(),
45+
'20241024 CodeWeek activities NOVEMBER CoderDojo Belgium.xlsx',
46+
'excel'
47+
);
48+
}
49+
}

app/Imports/CoderDojoEventsImport.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ public function parseDate($date)
2323

2424
public function model(array $row): ?Model
2525
{
26-
27-
// dd($row["start_date"]);
28-
//dd(implode(",",$arr));
29-
(\PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['start_date']));
30-
// dd(Carbon::parse($this->parseDate($row["start_date"]))->toDateTimeString());
31-
//dd(Carbon::createFromFormat("d/m/Y",$row["start_date"])->toDateTimeString());
32-
Log::info($row);
33-
3426
$event = new Event([
3527
'status' => 'APPROVED',
3628
'title' => $row['activity_title'],
@@ -41,10 +33,11 @@ public function model(array $row): ?Model
4133
'activity_type' => $row['activity_type'],
4234
'location' => isset($row['address']) ? $row['address'] : 'online',
4335
'event_url' => $row['organiser_website'],
36+
'contact_person' => !empty($row['contact_email']) ? $row['contact_email'] : '',
4437
'user_email' => '',
45-
'creator_id' => $row['creator_id'],
38+
'creator_id' => 132942,
4639
'country_iso' => $row['country'],
47-
'picture' => $row['image_path'],
40+
'picture' => isset($row['image_path']) ? $row['image_path'] : '',
4841
'pub_date' => now(),
4942
'created' => now(),
5043
'updated' => now(),
@@ -54,7 +47,7 @@ public function model(array $row): ?Model
5447
'geoposition' => $row['latitude'].','.$row['longitude'],
5548
'longitude' => $row['longitude'],
5649
'latitude' => $row['latitude'],
57-
'language' => 'nl',
50+
'language' => isset($row['language']) ? $row['language'] : 'nl',
5851
'approved_by' => 19588,
5952
'mass_added_for' => 'Excel',
6053
]);
Binary file not shown.

0 commit comments

Comments
 (0)