Skip to content

Commit

Permalink
wrong v.price
Browse files Browse the repository at this point in the history
  • Loading branch information
alkadoHs committed Feb 15, 2024
1 parent e70d22a commit 121b90c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Filament/Resources/OrderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,14 @@ function () {
])
->native(false)
->reactive()
->afterStateUpdated( fn (Get $get, Set $set, ?string $state): int
=> $set('price', $state == 'R' ? Product::find($get('product_id'))->mainProduct?->retail_price?? 0 :
Product::find($get('product_id'))->mainProduct?->whole_price?? 0)
)
->afterStateUpdated( function (Get $get, Set $set, ?string $state): int {
if(auth()->user()->role == 'vendor')
return $set('price', $state == 'R' ? VendorProduct::with('product.mainProduct')->where('id',$get('product_id'))->first()->product->mainProduct?->retail_price?? 0 :
VendorProduct::with('product.mainProduct')->where('id', $get('product_id'))->first()->product->mainProduct?->whole_price?? 0);

return $set('price', $state == 'R' ? Product::find($get('product_id'))->mainProduct?->retail_price?? 0 :
Product::find($get('product_id'))->mainProduct?->whole_price?? 0);
})
->required(),

Forms\Components\TextInput::make('quantity')
Expand Down

0 comments on commit 121b90c

Please sign in to comment.