1

I want to update the combobox, but when i run the program the error appears. the error said

Undefined variable: jenis (View: D:\laravel\makanan\resources\views\edit_upload.blade.php)

what is the solution and what sintax to use ?

this is sintax in the controller:

public function prosesedit($id, Request $request)
    {
        $makan = Gambar::find($id);
        $nama_file = $makan->file;
        $jenis = JenisMkn::select('id_jenis','jenis_makanan')->get();


        if($request->hasfile('file'))
        {
            $file = $request->file('file');
            $nama_file = time()."_".$file->getClientOriginalName();
            $tujuan_upload = 'image_file';
            $file->move($tujuan_upload,$nama_file);
        }

        $makan->update([
            'file'=>$nama_file,
            'nama_makanan'=>$request->makan,
            'kode_makanan'=>$request->jenis,
        ]);
        return redirect(route('makan'));
    }

and this is html

 <div class="form-group">
                    <b>Jenis Makanan</b>
                    <br/>
                    <select name="jenis" id="" class="form control input-sm">
                        @foreach ($jenis as $j)
                            <option value="{{$j->id_jenis}}">{{$j->jenis_makanan}}</option>
                        @endforeach
                    </select>
                </div>

help me please

1
  • Show us the code where you use the blade view.
    – ceejayoz
    Commented Sep 25, 2019 at 16:47

1 Answer 1

0

In Your edit function where you return the edit_upload.blade.php,with this return please pass the variable jenis like

return view('edit_upload',compact('jenis'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.