Kanchan186
2 weeks ago
216
20
Laravel

SQLSTATE[42S22]: Column not found: 1054 Unknown column ' head_offices.country_id' in 'on clause' (SQL: select * from `head_offices` inner join `countries` on ` head_offices`.`country_id` = `countries`.`country_id` inner join `states` on ` head_offices`.`s

Posted 2 weeks ago by Kanchan186

controller

public function show()
    {

      $HeadOffice=HeadOffice::join('countries',' head_offices.country_id','=','countries.country_id')
                            ->join('states',' head_offices.state_id','=','states.state_id')
                            ->join('cities',' head_offices.city_id','=','cities.city_id')
                            ->get();
        
        
        $country=Country::get();
        $state=State::get();
        $city=city::get();

        //return $names;
        return view('backend.head_office.viewHeadOffice',compact('country','state','city','HeadOffice'));
    }

view

          <div class="table-responsive m-t-40">
                                    <table id="example23" class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
                                        <thead>
                                            <tr>
                                                <th>Sr No</th>
                                                 <th>Country</th>
                                                <th>State</th>
                                                <th>City</th>
                                                <th>Head Office </th>
                                                <th>Operations</th>
                                            </tr>
                                        </thead>
                                       
                                        <tbody>

                                          <?php $i=1; ?>
                                          @foreach($HeadOffice as $hd)

                                            <tr>
                                                <td>{{$i++}}</td>
                                                <td>{{$hd->country_name}}</td>
                                                <td>{{$hd->state_name}}</td>
                                                <td>{{$hd->city_name}}</td>
                                                <td>{{$hd->head_office_name}}</td>
                                               
                                                <td>
                                                  <a href="{{url('/')}}/head_office/{{$hd->head_office_id}}/edit"><i class="fas fa-edit"></i></a>  
                                                  &nbsp;<a href="{{url('/')}}/head_office/{{$hd->head_office_id}}" onclick="return confirm('Do you want delete this record')"><i class="fas fa-trash" ></i>
                                                </td>
                                            </tr>

                                           @endforeach
                                            
                                        </tbody>
                                    </table>
                                </div>

Please sign in or create an account to participate in this conversation.