edit function
public function edit($id)
{
$spesifikasi = logistik_spesifikasi::find($id);
return view('logistik.edit_spesifikasi', get_defined_vars());
}
logistik_spesifikasi model
class logistik_spesifikasi extends Model
{
protected $table = 'logistik_spesifikasi';
protected $primarykey = 'id';
protected $fillable = ['nama_produk', 'satuan', 'tipe', 'jumlah', 'id_satuan','id_produk'];
public function listMaterial()
{
return $this->hasMany('App\ListMaterial', 'id_produk');
}
public function satuanList()
{
return $this->belongsTo('App\LogistikSatuan', 'id_satuan');
}
}
ListMaterial Model:
class ListMaterial extends Model
{
protected $table = 'list_material';
protected $primarykey = 'id';
public $timestamps = false;
protected $fillable = ['id_material', 'id_produk', 'volume'];
public function material()
{
return $this->hasMany('App\material', 'id_material');
}
}
edit_spesifikasi.blade.php
<thead>
<tr>
<th>Nama Material</th>
</tr>
</thead>
<tbody>
@foreach($spesifikasi as $row )
<tr class="gradeU">
<td>{{ $row->listMaterial->first()->material->first()->nama_material }}</td>
</tr>
@endforeach
</tbody>
gettting error
Trying to get property of non-object (View: C:\xampp\htdocs\hutama-prima\resources\views\logistik\edit_spesifikasi.blade.php)