Build a tax dropdown for further usage.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\View\Composers\TaxDropdown;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Translation\Translator;
|
use Illuminate\Translation\Translator;
|
||||||
|
|
||||||
@@ -29,6 +30,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
//
|
\Illuminate\Support\Facades\View::composer('components.tax-dropdown', TaxDropdown::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
app/View/Composers/TaxDropdown.php
Normal file
16
app/View/Composers/TaxDropdown.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Composers;
|
||||||
|
|
||||||
|
use App\Models\Taxrate;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class TaxDropdown
|
||||||
|
{
|
||||||
|
public function compose(View $view): void
|
||||||
|
{
|
||||||
|
$standard = Taxrate::where('active', true)->first();
|
||||||
|
|
||||||
|
$view->with(['tax_rates' => TaxRate::all(), 'standard' => $standard->rate]);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
resources/views/components/tax-dropdown.blade.php
Normal file
15
resources/views/components/tax-dropdown.blade.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<div x-data="{ selectedOption: {{ $standard }}, tax_rates: {{ $tax_rates }} }">
|
||||||
|
<div class="w-80 flex pr-3">
|
||||||
|
<x-input-label for="tax_rate" :value="__('configuration.Taxrate')"/>
|
||||||
|
<div class="inline-block relative ">
|
||||||
|
<select name="tax_rate" x-model="selectedOption"
|
||||||
|
class="border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm"
|
||||||
|
x-on:change="console.log(selectedOption);" x-init="console.log(selectedOption);">
|
||||||
|
<template x-for="tax_rate in tax_rates" :key="tax_rate.id">
|
||||||
|
<option :value="tax_rate.rate" x-text="tax_rate.rate_percentage"
|
||||||
|
:selected="tax_rate.active"></option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user