Level 3
anyone help me
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
show-proposals.blade.php
<x-button wire:click="triggerDownload('{{ $proposal->id }}')" style="background-color: #3d83f6; hover:bg-blue-700">Export PDF</x-button>
</td>```
ShowProposals.php
```<?php
namespace App\Http\Livewire;
use App\Models\Proposal;
use Exception;
use Livewire\Component;
use Livewire\WithPagination;
use Illuminate\Support\Facades\Log;
class ShowProposals extends Component
{
use WithPagination;
protected $listeners = ['deleteProposal'];
public function triggerDownload($proposalId)
{
//dd($proposalId);
$this->emit('downloadProposalPdf', $proposalId);
}
public function render()
{
return view('livewire.show-proposals',[
'proposals' => Proposal::orderBy('updated_at', 'desc')->paginate(10),
]);
}
public function deleteProposal($proposalId)
{
Log::info('Delete Proposal Event Triggered:', ['id' => $proposalId]);
try {
$proposal = Proposal::findOrFail($proposalId);
$proposal->delete();
session()->flash('message', 'Proposal deleted successfully.');
return redirect()->route('dashboard'); // Adjust the route as needed
} catch (\Exception $e) {
Log::error('Error deleting proposal:', ['error' => $e->getMessage()]);
}
}
}
ProposalPdf
namespace App\Http\Livewire;
use App\Models\Proposal;
use Livewire\Component;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Support\Facades\Log;
class ProposalPdf extends Component
{
public $listeners = ['downloadProposalPdf'=> 'downloadProposalPdf'];
public function downloadProposalPdf($proposalId)
{
Log::info('Listener Triggered', $proposalId);
$data = Proposal::find($proposalId); // Use $proposal->id to find the proposal
//dd($data['overseas_conditions']);
dd($data);
if (!$data) {
abort(404); // Handle if proposal not found
}
$pdf = PDF::loadView('livewire.proposal-pdf', ['data' => $data]);
//log:info($pdf);
return $pdf->download('Agile Courts - Proposal');// Stream the PDF to the browser
}
// public function render()
// {
// return view('livewire.proposal-pdf');
// }
}```
not event enter into this method downloadProposalPdf
can you pls help me
Please or to participate in this conversation.