Archived
feat: basic quotes request
This commit is contained in:
1 parent
4fdff98580
commit
a918600813
12 files changed
+165
-24
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<div>
|
||||
<div class="flex h-16 shrink-0 items-center border-b border-gray-200">
|
||||
<a href="{{ route('dashboard') }}" wire:navigate>
|
||||
<a href="{{ route('home') }}" wire:navigate>
|
||||
<img class="h-12 w-auto" src="https://benjamyn.love/PriceyBot.png" alt="">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<x-guest-layout>
|
||||
<div class="flex flex-col mt-8">
|
||||
<livewire:pages.quote.request/>
|
||||
|
||||
<livewire:pages.quote.requested/>
|
||||
|
||||
<livewire:pages.quote.list/>
|
||||
<livewire:pages.quote.list/>
|
||||
</div>
|
||||
</x-guest-layout>
|
||||
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Quote;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Rule;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new #[Layout('layouts.guest')] class extends Component
|
||||
@@ -14,7 +11,7 @@ new #[Layout('layouts.guest')] class extends Component
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->quotes = Quote::all()->sortDesc();
|
||||
$this->quotes = Quote::all()->whereNull('deleted_at')->sortDesc();
|
||||
}
|
||||
}; ?>
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Quote;
|
||||
use App\Models\RequestedQuotes;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Rule;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new #[Layout('layouts.guest')] class extends Component
|
||||
{
|
||||
#[Rule(['required', 'string', 'unique:requested_quotes,quote'])]
|
||||
public string $quote = '';
|
||||
|
||||
public function store(): void
|
||||
{
|
||||
$validated = $this->validate();
|
||||
|
||||
RequestedQuotes::create([
|
||||
'quote' => $validated['quote'],
|
||||
'user_id' => auth()->user()->id ?? null,
|
||||
]);
|
||||
|
||||
$this->quote = '';
|
||||
|
||||
$this->dispatch('quote-requested');
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="px-4 sm:px-6 lg:px-8">
|
||||
<form wire:submit="store">
|
||||
<x-text-input
|
||||
wire:model="quote"
|
||||
placeholder="{{ __('What did he say this time?') }}"
|
||||
class="block w-full border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm"
|
||||
></x-text-input>
|
||||
|
||||
<x-input-error :messages="$errors->get('quote')" class="mt-2"/>
|
||||
<x-primary-button class="mt-4">{{ __('Request') }}</x-primary-button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Quote;
|
||||
use App\Models\RequestedQuotes;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Attributes\Rule;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new #[Layout('layouts.guest')] class extends Component
|
||||
{
|
||||
public Collection $quotes;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->getRequestedQuotes();
|
||||
|
||||
}
|
||||
|
||||
#[On('quote-requested')]
|
||||
public function getRequestedQuotes()
|
||||
{
|
||||
$this->quotes = RequestedQuotes::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">
|
||||
Requested Quotes
|
||||
</th>
|
||||
{{-- TODO: add logged in user stuff --}}
|
||||
</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>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user