lundi 11 juillet 2016

Make Modal Edit Pop up Laravel

i want to make modal popup for my edit form. i already make the popup but it wont to get the id.

here my veiw :

<a title='Edit Data' href="#" data-toggle="modal" class='btn btn-xs btn-warning' data-target="#moModal"><i class='fa fa-pencil'></i></a>

and my modal:

<div class="modal fade" id="moModal" role="dialog">
                    <div class="modal-dialog">
                        <div class="modal-content">
                        <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <center><h4>Edit</h4></center>
                        </div>
                        <div class="modal-body">
                            <form method='post' action='' enctype="multipart/form-data">
                                <input type="hidden" name="_token" value="">
                                <div class="box-body">
                                    <div class="box-body">
                                    <div class='form-group col-sm-6'>
                                        <label>Facilities</label>
                                        <input type='text' class='form-control' name='name_facility' value='' required/>
                                    </div>
                                    <div class='form-group col-sm-12'>
                                        <button type='submit' class='btn btn-primary'><i class='fa fa-save'></i> Simpan</button>
                                    </div>
                            </div><!-- /.box -->
                            </form>
                    </div>
                    </div>
                  </div>
                  </div>

here my controller :

public function getIndex()
    {
        $posts = DB::table('facilities')
        ->orderBy('id', 'asc');
        $posts = $posts->paginate(10);
        return view('facilities', ['posts' => $posts]);
    }
public function getEdit($id)  {
        $data['row'] = facilities::find($id);
        return view('facilities_form',$data);
    }
public function postEditSave($id) {
        $simpan= array();
        $simpan['name_facility']=Request::input('name_facility');

        DB::table('facilities')->where('id', $id)->update($simpan);
        Session::flash('edit', 'Data successfully edited');
        return Redirect::to('facilities');
    }

so, have someone help me what improvements do i have to make to the code to achieve my goal?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire