i am beginner in laravel. I want to update a data but I get an error like this : Trying to get property 'id' of non-object'
This is my Controller :
public function hitung(Request $request)
{
$tanggal = date("Y-m-d");
$keuangan = array(
'bahan_baku' => $request->bahan_baku,
'biaya_tambahan' => $request->biaya_tambahan,
'jumlah_tempe' => $request->jumlah_tempe,
'biaya_produksi' => $request->bahan_baku + $request->biaya_tambahan,
'hasil_penjualan' => $request->jumlah_tempe * 1000,
'hasil_pendapatan' => ($request->jumlah_tempe * 1000) - ($request->bahan_baku + $request->biaya_tambahan),
'tanggal' => $tanggal,
);
Keuangan::create($keuangan);
return view('keuangan.hasil', compact('keuangan'));
}
public function edit($id)
{
$keuangan = Keuangan::find($id);
return view('/keuangan/edit', compact('keuangan'));
}
}
This is section from my view :
@extends('layouts.master')
@section('title','Manajemen Keuangan')
@section('content')
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<div class="form-group">
<h4>Keuangan :<strong style="color: red;"> {{ Carbon\Carbon::parse( $keuangan['tanggal'] )->translatedFormat("d F Y") }} </strong></h4>
</div>
<table class="table table-borderless">
<tbody>
<tr>
<td><strong>Biaya Produksi</strong></td>
<td>:    Rp. {{ number_format($keuangan['biaya_produksi']) }}</td>
</tr>
<tr>
<td><strong>Hasil Penjualan</strong></td>
<td>:    Rp. {{ number_format($keuangan['hasil_penjualan']) }}</td>
</tr>
<td><hr></td>
<td><hr align="left" style="width: 25%;"></td>
<tr>
<td><strong>Hasil Pendapatan</strong></td>
<td>:    Rp. {{ number_format($keuangan['hasil_pendapatan']) }}</td>
</tr>
</tbody>
</table>
@if($keuangan)
<a href="/keuangan/{{ $keuangan->id }}/edit" class="btn btn-primary">Edit</a>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
@stop
this is my route :
Route::get('/keuangan/edit/{id}', 'KeuanganController@edit');
this is section from my model :
class Keuangan extends Model
{
protected $table = 'keuangan';
protected $fillable = ['id', 'bahan_baku', 'biaya_tambahan', 'biaya_produksi', 'jumlah_tempe', 'hasil_penjualan', 'hasil_pendapatan'];
}
where is my fault ?? I just want to make an edit to the my data