Skip to content

Commit 6e444cd

Browse files
committed
add resource helper
1 parent 35702b6 commit 6e444cd

File tree

10 files changed

+45
-22
lines changed

10 files changed

+45
-22
lines changed

composer.json

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"phpunit/phpunit": "^9.5"
3838
},
3939
"autoload": {
40+
"files": [
41+
"src/helpers.php"
42+
],
4043
"psr-4": {
4144
"Coderflex\\LaravelCsv\\": "src",
4245
"Coderflex\\LaravelCsv\\Database\\Factories\\": "database/factories"

config/laravel_csv.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<?php
22

33
return [
4-
//
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Default Layout
8+
|--------------------------------------------------------------------------
9+
|
10+
| This package came with multiple layouts to serve your need, and
11+
| currently it supports "tailwindcss" and "bootstrap", by default
12+
| the layout is tailwind.
13+
| currently support: "tailwindcss", "bootstrap"
14+
|
15+
*/
16+
'layout' => 'tailwindcss',
517
];

database/factories/ModelFactory.php

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
{{-- Handle Imports --}}
3+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
{{-- Import CSV --}}
3+
</div>

src/Http/Livewire/CsvImporter.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Validation\Validator;
1111
use Livewire\Component;
1212
use Livewire\WithFileUploads;
13+
use function Coderflex\LaravelCsv\csv_view_path;
1314

1415
class CsvImporter extends Component
1516
{
@@ -78,7 +79,9 @@ public function import()
7879

7980
public function render()
8081
{
81-
return view('laravel-csv::livewire.import-csv');
82+
return view(
83+
csv_view_path('import-csv')
84+
);
8285
}
8386

8487
protected function validationAttributes()

src/Http/Livewire/HandleImports.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Coderflex\LaravelCsv\Models\Import;
66
use Livewire\Component;
7+
use function Coderflex\LaravelCsv\csv_view_path;
78

89
class HandleImports extends Component
910
{
@@ -30,6 +31,8 @@ public function getImportsProperty()
3031

3132
public function render()
3233
{
33-
return view('laravel-csv::livewire.handle-imports');
34+
return view(
35+
csv_view_path('handle-imports')
36+
);
3437
}
3538
}

src/helpers.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Coderflex\LaravelCsv;
4+
5+
if (! function_exists('Coderflex\LaravelCsv\csv_view_path')) {
6+
/**
7+
* Get the evaluated view content from the livewire view
8+
*
9+
* @param string|null $view
10+
* @return string
11+
*/
12+
function csv_view_path($view) {
13+
return 'laravel-csv::livewire.' . config('laravel_csv.layout') . '.' . $view;
14+
}
15+
}

0 commit comments

Comments
 (0)