lundi 13 juin 2016

Error SQLSTATE[42000] Laravel Update

i have an application i want to make update data, but I find an error in my system when i want to update the data without change. but if I changed one of data my update successfully.

here my Controller :

public function getDetails($id)  {
        $data['row'] = data_kos::find($id);

        return view('details_add',$data);
    }

    public function postDetailsSave($id) {
        $simpan= array();
        if (Request::hasfile('photo1')) {
        $destinationPath = 'uploads'; // upload path
        $extension = Request::file('photo1')->getClientOriginalExtension(); // getting image extension
        $fileName = rand(11111,99999).'.'.$extension; // renameing image
        Request::file('photo1')->move($destinationPath, $fileName); // uploading file to given path
        $simpan['photo1']=$fileName;
    }
        if (Request::hasfile('photo2')) {
        $destinationPath1 = 'uploads'; // upload path
        $extension1 = Request::file('photo2')->getClientOriginalExtension(); // getting image extension
        $fileName1 = rand(11111,99999).'.'.$extension1; // renameing image
        Request::file('photo2')->move($destinationPath1, $fileName1); // uploading file to given path
        $simpan['photo2']=$fileName1;
    }
        if (Request::hasfile('photo3')) {
        $destinationPath2 = 'uploads'; // upload path
        $extension2 = Request::file('photo3')->getClientOriginalExtension(); // getting image extension
        $fileName2 = rand(11111,99999).'.'.$extension2; // renameing image
        Request::file('photo3')->move($destinationPath2, $fileName2); // uploading file to given path
        $simpan['photo3']=$fileName2;
    }
    if (Request::hasfile('photo4')) {
        $destinationPath3 = 'uploads'; // upload path
        $extension3 = Request::file('photo4')->getClientOriginalExtension(); // getting image extension
        $fileName3 = rand(11111,99999).'.'.$extension3; // renameing image
        Request::file('photo4')->move($destinationPath3, $fileName3); // uploading file to given path
        $simpan['photo4']=$fileName3;
    }
    if (Request::hasfile('photo5')) {
        $destinationPath4 = 'uploads'; // upload path
        $extension4 = Request::file('photo5')->getClientOriginalExtension(); // getting image extension
        $fileName4 = rand(11111,99999).'.'.$extension4; // renameing image
        Request::file('photo5')->move($destinationPath4, $fileName4); // uploading file to given path
        $simpan['photo5']=$fileName4;
    }

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

and here my view :

<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-12'>
                        <label>Title</label>
                        <input type='text' class='form-control' name='title' value='' readonly />
                    </div>
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" height="70px">
                        <input type='file' class='form-control' name='photo1' value=''/>
                    </div><br>
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" height="70px">
                        <input type='file' class='form-control' name='photo2' value=''/>
                    </div>
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" height="70px">
                        <input type='file' class='form-control' name='photo3' value=''/>
                    </div>
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" height="70px">
                        <input type='file' class='form-control' name='photo4' value=''/>
                    </div>
                    <div class='form-group col-sm-4'>
                        <label>gambar</label><br>
                        <img src="../../uploads/" height="70px">
                        <input type='file' class='form-control' name='photo5' value=''/>
                    </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>

here my table this my table anyone can give me solution ? for my problem

and here my error here my error



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire