feat: Implement withTrashed for polymorphic relationships, enable live updates for order form inputs, and eager load purchase items.
This commit is contained in:
parent
12053e18f7
commit
9cf985e8f9
@ -130,7 +130,6 @@ public function columns(): array
|
|||||||
if (auth()->user()->can('delete order')) {
|
if (auth()->user()->can('delete order')) {
|
||||||
$actions .= view('components.actions.table.delete', [
|
$actions .= view('components.actions.table.delete', [
|
||||||
'id' => $row->hash,
|
'id' => $row->hash,
|
||||||
'deleteRoute' => route('studio.manage.order.delete', $row->hash),
|
|
||||||
])->render();
|
])->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,6 @@ public function columns(): array
|
|||||||
if (auth()->user()->can('delete purchase')) {
|
if (auth()->user()->can('delete purchase')) {
|
||||||
$actions .= view('components.actions.table.delete', [
|
$actions .= view('components.actions.table.delete', [
|
||||||
'id' => $row->hash,
|
'id' => $row->hash,
|
||||||
'deleteRoute' => route('studio.manage.purchase.delete', $row->hash),
|
|
||||||
])->render();
|
])->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ public function columns(): array
|
|||||||
public function builder(): Builder
|
public function builder(): Builder
|
||||||
{
|
{
|
||||||
return Purchase::select('purchases.id', 'outlet_id', 'invoice_number', 'purchase_date', 'total')
|
return Purchase::select('purchases.id', 'outlet_id', 'invoice_number', 'purchase_date', 'total')
|
||||||
->with('outlet')
|
->with(['outlet', 'items', 'items.purchasable'])
|
||||||
->whereIn('outlet_id', auth()->user()->outlets->pluck('id')->toArray());
|
->whereIn('outlet_id', auth()->user()->outlets->pluck('id')->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
use App\Traits\Utilities\WithUpdatedData;
|
use App\Traits\Utilities\WithUpdatedData;
|
||||||
use Flux\Flux;
|
use Flux\Flux;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
|
||||||
use Livewire\Attributes\On;
|
use Livewire\Attributes\On;
|
||||||
use Livewire\Attributes\Title;
|
use Livewire\Attributes\Title;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public function user(): BelongsTo
|
|||||||
|
|
||||||
public function orderable(): MorphTo
|
public function orderable(): MorphTo
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo()->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function volumes(): HasMany
|
public function volumes(): HasMany
|
||||||
|
|||||||
@ -43,6 +43,6 @@ public function user(): BelongsTo
|
|||||||
|
|
||||||
public function purchasable(): MorphTo
|
public function purchasable(): MorphTo
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo()->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@
|
|||||||
<flux:tab.panel name="new">
|
<flux:tab.panel name="new">
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<flux:select label="Parfum" variant="listbox" searchable
|
<flux:select label="Parfum" variant="listbox" searchable
|
||||||
placeholder="Cari parfum..." wire:model="form.perfume_id">
|
placeholder="Cari parfum..." wire:model.live="form.perfume_id">
|
||||||
@foreach ($perfumes as $key => $perfume)
|
@foreach ($perfumes as $key => $perfume)
|
||||||
<flux:select.option value="{{ $key }}"
|
<flux:select.option value="{{ $key }}"
|
||||||
wire:key="new-{{ $key }}">
|
wire:key="new-{{ $key }}">
|
||||||
@ -97,7 +97,7 @@
|
|||||||
</flux:select>
|
</flux:select>
|
||||||
|
|
||||||
<flux:select label="Botol" variant="listbox" searchable placeholder="Cari botol..."
|
<flux:select label="Botol" variant="listbox" searchable placeholder="Cari botol..."
|
||||||
wire:model="form.bottle_id">
|
wire:model.live="form.bottle_id">
|
||||||
@foreach ($bottles as $key => $bottle)
|
@foreach ($bottles as $key => $bottle)
|
||||||
<flux:select.option value="{{ $key }}"
|
<flux:select.option value="{{ $key }}"
|
||||||
wire:key="new-{{ $key }}">{{ $bottle }}
|
wire:key="new-{{ $key }}">{{ $bottle }}
|
||||||
@ -107,7 +107,7 @@
|
|||||||
|
|
||||||
<div class="col-span-1 md:col-span-2">
|
<div class="col-span-1 md:col-span-2">
|
||||||
@if (!empty($qualities))
|
@if (!empty($qualities))
|
||||||
<flux:radio.group label="Kualitas" wire:model="form.quality_id"
|
<flux:radio.group label="Kualitas" wire:model.live="form.quality_id"
|
||||||
variant="buttons" class="w-full *:flex-1">
|
variant="buttons" class="w-full *:flex-1">
|
||||||
@foreach ($qualities as $key => $value)
|
@foreach ($qualities as $key => $value)
|
||||||
<flux:radio value="{{ $key }}"
|
<flux:radio value="{{ $key }}"
|
||||||
@ -130,7 +130,7 @@
|
|||||||
<flux:tab.panel name="refill">
|
<flux:tab.panel name="refill">
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
<flux:select label="Parfum" variant="listbox" searchable
|
<flux:select label="Parfum" variant="listbox" searchable
|
||||||
placeholder="Cari parfum..." wire:model="form.perfume_id">
|
placeholder="Cari parfum..." wire:model.live="form.perfume_id">
|
||||||
@foreach ($perfumes as $key => $perfume)
|
@foreach ($perfumes as $key => $perfume)
|
||||||
<flux:select.option value="{{ $key }}"
|
<flux:select.option value="{{ $key }}"
|
||||||
wire:key="refill-{{ $key }}">
|
wire:key="refill-{{ $key }}">
|
||||||
@ -143,7 +143,7 @@
|
|||||||
<flux:label>Ukuran Botol</flux:label>
|
<flux:label>Ukuran Botol</flux:label>
|
||||||
<flux:input.group>
|
<flux:input.group>
|
||||||
<flux:input placeholder="Masukkan ukuran botol"
|
<flux:input placeholder="Masukkan ukuran botol"
|
||||||
x-mask:dynamic="$money($input, ',')" wire:model="form.bottle_size"
|
x-mask:dynamic="$money($input, ',')" wire:model.live="form.bottle_size"
|
||||||
autocomplete="off" />
|
autocomplete="off" />
|
||||||
<flux:input.group.suffix>ml</flux:input.group.suffix>
|
<flux:input.group.suffix>ml</flux:input.group.suffix>
|
||||||
</flux:input.group>
|
</flux:input.group>
|
||||||
@ -151,7 +151,7 @@
|
|||||||
|
|
||||||
<div class="col-span-1 md:col-span-2">
|
<div class="col-span-1 md:col-span-2">
|
||||||
@if (!empty($qualities))
|
@if (!empty($qualities))
|
||||||
<flux:radio.group label="Kualitas" wire:model="form.quality_id"
|
<flux:radio.group label="Kualitas" wire:model.live="form.quality_id"
|
||||||
variant="buttons" class="w-full *:flex-1">
|
variant="buttons" class="w-full *:flex-1">
|
||||||
@foreach ($qualities as $key => $value)
|
@foreach ($qualities as $key => $value)
|
||||||
<flux:radio value="{{ $key }}"
|
<flux:radio value="{{ $key }}"
|
||||||
@ -182,7 +182,7 @@
|
|||||||
|
|
||||||
<flux:card class="space-y-6 p-6">
|
<flux:card class="space-y-6 p-6">
|
||||||
<flux:select label="Produk" variant="listbox" searchable placeholder="Cari produk..."
|
<flux:select label="Produk" variant="listbox" searchable placeholder="Cari produk..."
|
||||||
wire:model="form.product_id">
|
wire:model.live="form.product_id">
|
||||||
@foreach ($products as $key => $product)
|
@foreach ($products as $key => $product)
|
||||||
<flux:select.option value="{{ $key }}"
|
<flux:select.option value="{{ $key }}"
|
||||||
wire:key="product-{{ $key }}">{{ $product }}
|
wire:key="product-{{ $key }}">{{ $product }}
|
||||||
@ -191,7 +191,7 @@
|
|||||||
</flux:select>
|
</flux:select>
|
||||||
|
|
||||||
<flux:input label="Kuantitas" placeholder="Masukkan kuantitas produk"
|
<flux:input label="Kuantitas" placeholder="Masukkan kuantitas produk"
|
||||||
wire:model="form.quantity_product" autocomplete="off"
|
wire:model.live="form.quantity_product" autocomplete="off"
|
||||||
x-mask:dynamic="$money($input, ',')" />
|
x-mask:dynamic="$money($input, ',')" />
|
||||||
|
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-end">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user