This repository has been archived on 2024-05-20. You can view files and clone it, but cannot push or open issues or pull requests.

68 lines
2.3 KiB
PHP

<?php
use App\Models\Quote;
use Illuminate\Database\Eloquent\Collection;
use Livewire\Attributes\Layout;
use Livewire\Attributes\On;
use Livewire\Volt\Component;
new #[Layout('layouts.guest')] class extends Component
{
public Collection $quotes;
public function mount(): void
{
$this->getQuotes();
}
public function request(Quote $quote): void
{
$this->authorize('request', $quote);
$quote->request();
// TODO: add code to send a notification
}
#[On('quote-approved')]
public function getQuotes(): void
{
$this->quotes = Quote::all()->whereNull('deleted_at')->sortDesc();
}
}; ?>
<div class="px-4 sm:px-6 lg:px-8">
<div class="-mx-4 mt-10 ring-1 ring-gray-300 sm:mx-0 sm:rounded-lg bg-nexi-primary dark:bg-zinc-800 transition-colors duration-300">
<table class="min-w-full divide-y divide-gray-300">
<thead>
<tr>
<th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-nexi-black dark:text-gray-200 sm:pl-6">
Quotes
</th>
@if(auth()->user())
<th scope="col"></th>
@endif
</tr>
</thead>
<tbody>
@foreach ($quotes as $quote)
<tr>
<td class="relative py-4 pl-4 pr-3 text-sm sm:pl-6 border-t text-nexi-black dark:text-gray-200">
{{ $quote->quote }}
</td>
@if(auth()->user())
<td class="relative w-8 pl-4 pr-3 text-sm sm:pl-6 border-t">
<div class="flex flex-row space-x-2">
<form wire:submit="request({{ $quote }})">
<x-primary-button wire:loading.attr="disabled" wire:loading.class="opacity-50" class="bg-nexi-purple w-24">{{ __('Request') }}</x-primary-button>
</form>
</div>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
</div>