Hai ,
I have a problem, which is meant by livewire.js? id = baf105a7de86deee8ac1: 1752 Uncaught (in promise) TypeError: Cannot read property ‘data’ of null, and how to check for problems
livewire code
public $plu='';
public $buttun_disable='';
protected $listeners = ['renderrecipt' => '$refresh'];
public function cari_plu_master()
{
$today = \Carbon\carbon::today();
$now = \Carbon\carbon::now();
$cek_data_plu = master_item::where('plu',$this->plu)->exists();
$cek_data_recipt = proses_recipt::wheredate('tgl_recipt',$today)->where('plu',$this->plu)->exists();
// dd($cek_data_plu,$cek_data_recipt);
if ($cek_data_plu == true) {
//cek pernah input plu pada tanggal sama untuk recipt
if ($cek_data_recipt == false) {
$data_plu = master_item::where('plu',$this->plu)->first();
//create data
proses_recipt::create([
'plu'=> $data_plu->plu,
'deskripsi'=> $data_plu->deskripsi,
'stok_lama'=>$data_plu->stok,
'tgl_recipt'=>$now,
'user_proses'=>Auth::user()->name,
]);
$this->emit('renderrecipt');
} else {
$data_recipt = proses_recipt::wheredate('tgl_recipt',$today)
->where('plu',$this->plu)->first();
proses_recipt::wheredate('tgl_recipt',$today)
->where('plu',$this->plu)->update([
'stok_masuk'=> $data_recipt->stok_masuk+1,
]);
}
} else {
$this->emit('msgtidakadadimaster');
}
}
public function render()
{
$today = \Carbon\carbon::today();
$cek_isi_recip = proses_recipt::exists();
$list = proses_recipt::wheredate('tgl_recipt',$today)
->where('flag',0)->get();
return view('livewire.recipt',[
'list'=>$list,
'ds' =>$cek_isi_recip
]);
}
view blade
<div class="card-body">
<div class="form-group">
<label for="formGroupExampleInput">PLU / Barang</label>
<input wire:model="plu" wire:keydown.enter="cari_plu_master" type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col">
<table class="table table-bordered table-sm">
<thead>
<tr>
<th>
#
</th>
<th>
PLU
</th>
<th>
DESKRIPSI
</th>
<th>
STOK MASUK
</th>
<th>
STOK LAMA
</th>
<th>
TANGGAL RECIPT
</th>
<th>
ACTION
</th>
</tr>
</thead>
<tbody>
@foreach ($list as $no=>$item)
<tr>
<td>{{$no+1}}</td>
<td>{{$item->plu}}</td>
<td>{{$item->deskripsi}}</td>
{{-- <td>@livewire('qty-recipt',$item->plu,$item->stok_masuk){{$item->stok_masuk}}</td> --}}
<td>{{$item->stok_masuk}}@livewire('qty-recipt')</td>
<td>{{$item->stok_lama}}</td>
<td>{{$item->tgl_recipt}}</td>
<td>
<button wire:click='deleteitem({{$item->id}})' class="btn btn-danger"><li class="fa fa-trash"></li></button>
{{-- <button wire:click = "editqty" type="button" class="btn btn-primary">
<li class="fa fa-edit "></li>
</button> --}}
<button wire:click = "editqty({{$item->id}})" type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
<li class="fa fa-edit "></li>
</button>
{{-- @livewire('qty-recipt',$item->plu) --}}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col">
<button class="btn btn-info" {{empty($ds) ? 'disabled':'' }}>Save</button>
</div>
</div>
thanks