Monday, March 20, 2017

Edit Dynamic Form Laravel

I've seriou problem because of this error, i can't find any way, and now only hope to all of you guys to help me out, please kindly help

The condition is I've 2 table 'Tindakan' and 'Analisa' also 1 ID tindakan can have many Analisa. is it clear ? now i want to SHOW and EDIT my table analisa

here is my Controller

public function edittindaklanjut($id){
    $halaman="tindaklayanan";
    $tindakan=tindakan::findOrFail($id);
    $values = explode(",", $tindakan->revisi_dokumen);
    $analisa=DB::table('analisas')
    ->select(DB::raw('id,id_tindakan,analisa,tindakan,pic,tanggal_pelaksanaan'))
    ->where('id_tindakan','=',$id)->get();
    return view('layanankonsumen.edittindaklanjut',compact('tindakan','values','analisa','halaman'));
}

and this is my view

<table  id="tbanalisa">
            <thead>
              <tr>
                <th width="30%">Analisa Penyebab</th>
                <th width="30%">Tindakan Perbaikan dan Pencegahan</th>
                <th>PIC</th>
                <th>Waktu Pelaksanaan</th>
              </tr>
            </thead>

            <tbody>
              <tr>
                <td><textarea class="form-control" rows="3" name="analisa[]" placeholder="Analisa Penyebab" style="resize: none;
                height: 50px"></textarea></td>
                <td><textarea class="form-control" rows="3" name="tindakan[]" placeholder="Tindakan Perbaikan dan Pencegahan" 
                style="resize: none; height: 50px"></textarea></td>
                <td><input class="form-control" type="text" name="pic[]" placeholder="PIC" value=""></td>
                <td><input class="form-control" type="date" name="tanggal_pelaksanaan[]" class="picker__table" value=""></td>
              </tr>
            </tbody>
          </table>

First of all, i got an error Trying to get property of non-object because of get() when i change get with first() its show but only 1 row (i've 2 Row in analsia Please look at my Table on DB)



via Christianus Andre

Advertisement