jeudi 25 février 2016

how to update data in laravel 5?

My html form in laravel 5.how to display and edit data in laravel form.

 {!!  Form::open(array('url' => 'addstaff','class'=>'form-signin')) !!}

            <div class="row" style="margin-top:-20px;">
                <div class="col-md-12">
                    <h1 class="page-head-line">&nbsp;Staff
                    <div class="col-sm-12" style="font-size:12px">
                            <div class="row" style="margin-top:20px;">
                                <div class="form-group col-sm-2 col-xs-6">
                                <label>Title&nbsp;</label>
                               {!!  Form::select('title', array('1' => 'Select', 'Mr.' => 'Mr.', 'Mrs.' => 'Mrs.','Miss' => 'Miss'), null, ['class' => 'form-control']);  !!}
                                </div>
                                <div class="form-group col-sm-5 col-xs-6">
                                    <label>First Name&nbsp;</label>

                                {!!  Form::text('fname','',array('class' => 'form-control' ,'id' => 'fname' , "placeholder" => 'First Name')) !!}
                                </div>
                                <div class="form-group col-sm-5 col-xs-6">
                                    <label>Second Name&nbsp;</label>
                                    {!!  Form::text('sname','',array('class' => 'form-control' ,'id' => 'fname' , "placeholder" => 'Second Name')) !!}
                                </div>
                                <div class="form-group col-sm-3 col-xs-6">
                                    <label>Aadhar </label>
                                    {!!  Form::text('Aadhar','',array('class' => 'form-control' ,'id' => 'Aadhar' , "placeholder" => 'Aadhar Card No.')) !!} 
                                </div>
                                <div class="form-group col-sm-3 col-xs-6">
                                    <label>PAN Card </label>
                                     {!!  Form::text('pan','',array('class' => 'form-control' ,'id' => 'Aadhar' , "placeholder" => 'PAN Card No.')) !!}
                                </div>
                                <div class="form-group col-sm-3 col-xs-6">
                                    <label>Mobile No.</label>
                                     {!!  Form::text('mobile','',array('class' => 'form-control' ,'id' => 'mobile' , "placeholder" => 'Mobile No.')) !!}
                                </div>
                                <div class="form-group col-sm-3 col-xs-6">
                                    <label>Password</label>
                                    {!!  Form::password('Password',array('class' => 'form-control' ,'id' => 'Password' , "placeholder" => 'Password')) !!} 
                                </div>
                                <div class="form-group col-sm-4 col-xs-6">
                                    <label>Address 1</label>
                                     {!!  Form::text('Address1','',array('class' => 'form-control' ,'id' => 'Address1' , "placeholder" => 'Address 1')) !!}
                                </div>
                                <div class="form-group col-sm-4 col-xs-6">
                                    <label>Address 2</label>
                                  {!!  Form::text('Address2','',array('class' => 'form-control' ,'id' => 'Address1' , "placeholder" => 'Address 2')) !!}  

                                </div>
                                <div class="form-group col-sm-4 col-xs-6">
                                    <label>Address 3</label>
                                   {!!  Form::text('Address3','',array('class' => 'form-control' ,'id' => 'Address3' , "placeholder" => 'Landmark')) !!}   

                                </div>
                                <div class="form-group col-sm-3 col-xs-6">
                                    <label>City / Town</label>
                                    {!!  Form::text('city','',array('class' => 'form-control' ,'id' => 'city' , "placeholder" => 'City / Town')) !!}   
                                </div>
                                <div class="form-group col-sm-3 col-xs-6">
                                    <label>Pincode</label>
                                   {!!  Form::text('Pincode','',array('class' => 'form-control' ,'id' => 'Pincode' , "placeholder" => 'Pincode')) !!}      
                                </div>
                                <div class="form-group col-sm-3 col-xs-6">
                                    <label>State</label>
                                   {!!  Form::text('State','',array('class' => 'form-control' ,'id' => 'State' , "placeholder" => 'State')) !!}   

                                </div>
                            </div>
                            <div class="text-center">  {!!  Form::submit('Submit', array('class'=>'btn btn-primary btn-md')) !!}</div>
                        </div>
                       <br clear="all">

                        @if(Session::has('successs'))
              <div class="alert text-center alert-success" style="font-size:12px;">
                {!!Session::get('successs')!!} 
                  </div>
           @endif 



           @if(Session::has('error'))
              <div class="alert alert-danger">
                    {!!Session::get('error')!!} 
                     </div>
           @endif  
                    </h1>

                </div>
            </div>

          {!! Form::close() !!}   

Then in edit link I have written the code

<a href="<?php echo 'Editstaff/'.$row->staff_id; ?>" class="btn btn-xs btn-info" >Edit</a>

Then in Route file I have written the code like

Route::get('Editstaff/{id}', 'HomeController@Editstaff');

Then in controller file I have written the code like

public function Editstaff($id)
{

     $editdata = DB::table('staff')->where('staff_id','=',$id)->first(); 
    return View::make('staff',array('list' => $editdata));

}   

I want to update data first show in from when click on edit link ..can some one help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire