50 lines
1 KiB
PHP
50 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Projects;
|
|
|
|
use App\Livewire\Forms\MailingForm;
|
|
use App\Models\ProjectReport;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Livewire\Attributes\Reactive;
|
|
use Livewire\Component;
|
|
|
|
class ReportRow extends Component
|
|
{
|
|
protected $listeners = [
|
|
// 'Badge:refresh' => '$refresh',
|
|
];
|
|
|
|
public ProjectReport $report;
|
|
|
|
public MailingForm $mailingForm;
|
|
|
|
public bool $createMailingModal = false;
|
|
|
|
public function mount()
|
|
{
|
|
$this->mailingForm->setReport($this->report);
|
|
|
|
}
|
|
|
|
public function download()
|
|
{
|
|
$filePath = $this->report->project->download_path . '/' . $this->report->path;
|
|
|
|
if (!Storage::exists($filePath)) {
|
|
abort(404);
|
|
}
|
|
|
|
return Storage::download($filePath);
|
|
}
|
|
|
|
public function createMailing() {
|
|
$this->mailingForm->save();
|
|
$this->reset('createMailingModal');
|
|
}
|
|
|
|
public function render(){
|
|
logger(sprintf('%s %s', __CLASS__, $this->report->id));
|
|
return view('livewire.projects.report-row');
|
|
}
|
|
}
|