Build a tax dropdown for further usage.

This commit is contained in:
2024-12-11 12:51:10 +01:00
parent 6f70849621
commit 644adad9c3
3 changed files with 33 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Providers;
use App\View\Composers\TaxDropdown;
use Illuminate\Support\ServiceProvider;
use Illuminate\Translation\Translator;
@@ -29,6 +30,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
\Illuminate\Support\Facades\View::composer('components.tax-dropdown', TaxDropdown::class);
}
}

View 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]);
}
}