-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathHandleImports.php
46 lines (38 loc) · 1.04 KB
/
HandleImports.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Coderflex\LaravelCsv\Http\Livewire;
use function Coderflex\LaravelCsv\csv_view_path;
use Coderflex\LaravelCsv\Models\Import;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Livewire\Component;
class HandleImports extends Component
{
/** @var string */
public $model;
/** @var array */
protected $listeners = [
'imports.refresh' => '$refresh',
];
public function mount(string $model): void
{
$this->model = $model;
}
public function getImportsProperty(): Collection
{
/** @var \Illuminate\Foundation\Auth\User */
$user = auth()->user();
return Import::query()
->forModel($this->model)
->forUser($user->id)
->oldest()
->unCompleted()
->get();
}
public function render(): View|Factory
{
return view(
csv_view_path('handle-imports')
);
}
}