Skip to content

Commit d4e7ebc

Browse files
Make slug seperator overwritable in config to fix the created_at -> created-at problem, fixues issue SpartnerNL#41
1 parent de533ac commit d4e7ebc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Maatwebsite/Excel/Excel.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ class Excel extends PHPExcel
7878
*/
7979
public $limit = false;
8080

81+
/**
82+
* Slug seperator
83+
* @var string
84+
*/
85+
public $seperator = '-';
86+
8187
/**
8288
* Loaded view
8389
* @var [type]
@@ -162,6 +168,7 @@ public function __construct(PHPExcel $excel, HTML_reader $htmlReader, Config $co
162168
$this->calculate = $this->config->get('excel::calculate', $this->calculate);
163169
$this->ignoreEmpty = $this->config->get('excel::ignoreEmpty', $this->ignoreEmpty);
164170
$this->dateFormat = $this->config->get('excel::date_format', $this->dateFormat);
171+
$this->seperator = $this->config->get('excel::seperator', $this->seperator);
165172

166173
// Reset
167174
$this->reset();
@@ -854,7 +861,7 @@ private function getLabels()
854861
foreach ($this->row->getCellIterator() as $this->cell) {
855862

856863
// Set labels
857-
$this->labels[] = Str::slug($this->cell->getValue());
864+
$this->labels[] = Str::slug($this->cell->getValue(), $this->seperator);
858865

859866
}
860867

src/config/config.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@
4040

4141
'delimiter' => ',',
4242

43+
/*
44+
|--------------------------------------------------------------------------
45+
| Slug seperator
46+
|--------------------------------------------------------------------------
47+
|
48+
| The default seperator for the Str::slug() method.
49+
| If you have problemen with _ being converted to -, you can
50+
| change the seperator to _ here.
51+
|
52+
*/
53+
54+
'seperator' => '-',
55+
4356
/*
4457
|--------------------------------------------------------------------------
4558
| Calculate

0 commit comments

Comments
 (0)