fix edit products using new workflow mutations
This commit is contained in:
@@ -116,6 +116,13 @@ class MutationsController extends Controller
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
// Check if request came from transaction page
|
||||
if ($request->has('from_transaction_page') || str_contains($request->header('referer', ''), '/transaction')) {
|
||||
return redirect()->back()
|
||||
->with('success', 'Mutasi berhasil dibuat dan terkirim ke dealer tujuan');
|
||||
}
|
||||
|
||||
return redirect()->route('mutations.index')
|
||||
->with('success', 'Mutasi berhasil dibuat dan terkirim ke dealer tujuan');
|
||||
|
||||
|
||||
@@ -41,4 +41,11 @@ class Dealer extends Model
|
||||
{
|
||||
return $this->hasMany(Stock::class);
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'stocks', 'dealer_id', 'product_id')
|
||||
->withPivot('quantity')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,13 @@ class Product extends Model
|
||||
return $this->hasMany(MutationDetail::class);
|
||||
}
|
||||
|
||||
public function dealers()
|
||||
{
|
||||
return $this->belongsToMany(Dealer::class, 'stocks', 'product_id', 'dealer_id')
|
||||
->withPivot('quantity')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
// Helper method untuk mendapatkan total stock saat ini
|
||||
public function getCurrentTotalStockAttribute()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user