hello im trying to save my filename in database laravel , but it gives me im doing upload image with laravel. The image is uploaded yet the field from my rent database not. This is what happens.
Creating default object from empty value
im using Storage:link
Controller use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage;
public function insertproof(Request $request)
$id = $request['id'];
if ($request->hasFile('rent_proof')){
$filepath = $request->file('rent_proof')->store('app/folder_proof');
}
$result = rent::find($id);
$result->rent_proof=$filepath;
$result->save();
}
and here is my view and this view is from mymodal
<form method="POST" action="{{route('visitor_rent.insertproof')}}"
enctype="multipart/form-data">
{{ csrf_field() }}
<div class="form-group">
<input type="file" class="form-control" name="rent_proof" id="proof">
</div>
<button type="submit" class="btn btn-success">Save</button>
</form>
This is my model
public class Rent extends Model
{
protected $primaryKey = 'id';
protected $fillable = ['rent_proof'];
}
edit : hello this one that gives me the error
$result = rent::find($id);
$result->rent_proof=$filepath; //<--this line is giving me the error
$result->save();
thanks for the care is there anything that i miss?
Version laravel 5.5 PHP 7.2