«Неопределенное свойство: Larapack \ DoctrineSupport \ Connections \ MySqlConnection :: $ id» - PullRequest
0 голосов
/ 26 февраля 2019

Я создал окно поиска, я хочу найти местоположение. Я не знаю, почему он выдал ошибку по id, пожалуйста, помогите мне

controller.php

 public function index()
    {
        $states = HOStateMaster::getAllState();
        return view('vendor/voyager/Ho/index')->with('states',$states);
    }

    public function search(Request $request){

        $search = $request->get('search');
        $states = DB::table('state_city_master')->where('location','like','%'.$search.'%');
        return view('vendor/voyager/Ho/index')->with('states',$states);
    }

blade.php

<div class="search-container">
<form method="GET" action="{{ route('state-master.search') }}">
<div style="display:inline-flex"><input type="text" name="search" class="form-control"><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button></div>
</form>
</div>
</div>
<div class="card" >
  <div class="card-body">
<table class="table striped" style="overflow-x:auto!important;">
  <thead class="" style="background-color:black;">
    <tr> 
      <th scope="col">{{ "Id" }}</th>
      <th scope="col">{{ "Location" }}</th>
      <th scope="col">{{ "Posted Date" }}</th>
      <th scope="col">{{ "Action" }}</th>
    </tr>
  </thead>
  <tbody>
   @foreach($states as $key => $state)
    <tr class="@cbdms_details.IsOdd("odd","even")>
      <th scope="row">{{ $state->id }}</th>
      <td>{{ $state->location }}</td>
      <td>{{ date('Y-m-d',strtotime($state->created_at)) }}</td>
      <td>

Снимок экрана ошибки

error

1 Ответ

0 голосов
/ 26 февраля 2019

Вы забыли ->get()

public function search(Request $request){

    $search = $request->get('search');
    $states = DB::table('state_city_master')->where('location','like','%'.$search.'%')->get();
    return view('vendor/voyager/Ho/index')->with('states',$states);
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...