promonisme
parent
aad0387131
commit
7ce9077184
|
@ -114,10 +114,15 @@ class Transaksi extends Controller
|
||||||
|
|
||||||
foreach ($request->orderMenus as $key => $value) {
|
foreach ($request->orderMenus as $key => $value) {
|
||||||
// calculate produk promo untuk mengurangi stok
|
// calculate produk promo untuk mengurangi stok
|
||||||
// $produk = Produk::find($value['id']);
|
$produk = Produk::find($value['id']);
|
||||||
// dd($produk->stok_produk);
|
|
||||||
// $produk->stok_produk = $produk->stok_produk - $value['qty'];
|
foreach ($produk->kelompokKategori as $key => $value2) {
|
||||||
// $produk->save();
|
if ($value2->kode_kelompok_kategori == 'PROMO') {
|
||||||
|
$produk->stok_promo = $produk->stok_promo - $value['qty'];
|
||||||
|
$produk->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oderDatas = [
|
$oderDatas = [
|
||||||
'pesanan_id' => $pesananModels->id,
|
'pesanan_id' => $pesananModels->id,
|
||||||
'produk_id' => $value['id'],
|
'produk_id' => $value['id'],
|
||||||
|
|
|
@ -41,4 +41,9 @@ class Produk extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(KategoriProduk::class, 'kategori_produk_id');
|
return $this->belongsTo(KategoriProduk::class, 'kategori_produk_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function kelompokKategori()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(KelompokKategori::class, KelompokKategoriPivot::class, 'produk_id', 'kelompok_kategori_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('produks', function (Blueprint $table) {
|
||||||
|
$table->integer('stok_promo')->nullable()->after('stok_produk');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('produks', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('stok_promo');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -26,7 +26,7 @@ class ProdukSeeder extends Seeder
|
||||||
"varian_produk" => $data['4'] ?? null,
|
"varian_produk" => $data['4'] ?? null,
|
||||||
"harga_produk" => $data['5'] ?? '',
|
"harga_produk" => $data['5'] ?? '',
|
||||||
"urutan" => $data['6'] == "" ? null : $data['6'],
|
"urutan" => $data['6'] == "" ? null : $data['6'],
|
||||||
"stok_produk" => $data['7'] == "" ? null : $data['7'],
|
"stok_promo" => $data['7'] == "" ? null : $data['7'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$firstline = false;
|
$firstline = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ketegori_produk_id,kode_produk,nama_produk,deskripsi_produk,varian_produk,harga_produk,urutan,stok_produk
|
ketegori_produk_id,kode_produk,nama_produk,deskripsi_produk,varian_produk,harga_produk,urutan,stok_promo
|
||||||
2,NP,Nasi Putih,,,5000,1,
|
2,NP,Nasi Putih,,,5000,1,
|
||||||
2,NP T.KER SB.IJO,Paket Irit Nasi Putih Telur Keriting Sambal Ijo,,,10000,,
|
2,NP T.KER SB.IJO,Paket Irit Nasi Putih Telur Keriting Sambal Ijo,,,10000,,
|
||||||
2,NP T.KER SB.MTH,Paket Irit Nasi Putih Telur Keriting Sambal Matah,,,10000,,
|
2,NP T.KER SB.MTH,Paket Irit Nasi Putih Telur Keriting Sambal Matah,,,10000,,
|
||||||
|
|
|
|
@ -282,11 +282,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 mt-3">
|
<div class="col-md-12 mt-3">
|
||||||
@if (
|
@if (
|
||||||
$kelompokKategoriPivot->produk->stok_produk != '' ||
|
$kelompokKategoriPivot->produk->stok_promo != '' ||
|
||||||
$kelompokKategoriPivot->produk->stok_produk != 0 ||
|
$kelompokKategoriPivot->produk->stok_promo != 0 ||
|
||||||
$kelompokKategoriPivot->produk->stok_produk != null)
|
$kelompokKategoriPivot->produk->stok_promo != null)
|
||||||
<h6 style="color: red">Promo Tersisa:
|
<h6 style="color: red">Promo Tersisa:
|
||||||
{{ $kelompokKategoriPivot->produk->stok_produk ?? 0 }}
|
{{ $kelompokKategoriPivot->produk->stok_promo ?? 0 }}
|
||||||
</h6>
|
</h6>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue