feat: request quotes
This commit is contained in:
parent
1833146158
commit
fb679c3042
@ -9,6 +9,11 @@ class Quote extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
public function request()
|
||||
{
|
||||
// Send the notification
|
||||
// If success, add it to the transactions
|
||||
}
|
||||
protected $fillable = [
|
||||
'quote',
|
||||
];
|
||||
|
||||
17
app/Policies/QuotePolicy.php
Normal file
17
app/Policies/QuotePolicy.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Quote;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class QuotePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function request(): bool
|
||||
{
|
||||
return !empty(auth()->user());
|
||||
}
|
||||
}
|
||||
@ -15,11 +15,18 @@ new #[Layout('layouts.guest')] class extends Component
|
||||
$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();
|
||||
|
||||
}
|
||||
}; ?>
|
||||
|
||||
@ -32,7 +39,9 @@ new #[Layout('layouts.guest')] class extends Component
|
||||
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>
|
||||
{{-- TODO: add logged in user stuff --}}
|
||||
@if(auth()->user())
|
||||
<th scope="col"></th>
|
||||
@endif
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -41,6 +50,15 @@ new #[Layout('layouts.guest')] class extends Component
|
||||
<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 class="bg-nexi-purple w-24">{{ __('Request') }}</x-primary-button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user