Move files to computed property

This commit is contained in:
Marcus Moore 2024-07-16 16:08:42 -07:00
parent b7744105a0
commit 7e89b58746
No known key found for this signature in database
2 changed files with 10 additions and 4 deletions

View file

@ -5,12 +5,11 @@ namespace App\Livewire;
use App\Models\CustomField;
use App\Models\Import;
use Illuminate\Support\Facades\Storage;
use Livewire\Attributes\Computed;
use Livewire\Component;
class Importer extends Component
{
public $files;
public $progress = -1; //upload progress - '-1' means don't show
public $progress_message;
public $progress_bar_class = 'progress-bar-warning';
@ -545,6 +544,8 @@ class Importer extends Component
}
}
}
unset($this->files);
}
public function clearMessage()
@ -553,9 +554,14 @@ class Importer extends Component
$this->message_type = null;
}
#[Computed]
public function files()
{
return Import::orderBy('id', 'desc')->get();
}
public function render()
{
$this->files = Import::orderBy('id','desc')->get(); //HACK - slows down renders.
return view('livewire.importer')
->extends('layouts.default')
->section('content');

View file

@ -118,7 +118,7 @@
</th>
</tr>
@foreach($files as $currentFile)
@foreach($this->files as $currentFile)
<tr style="{{ ($activeFile && ($currentFile->id == $activeFile->id)) ? 'font-weight: bold' : '' }}" class="{{ ($activeFile && ($currentFile->id == $activeFile->id)) ? 'warning' : '' }}">
<td class="col-md-6">{{ $currentFile->file_path }}</td>