无效的文本表示形式:整数“ edit”的无效输入语法

时间:2019-12-08 12:21:43

标签: php laravel vue.js

我在Laravel Blade文件中包含“所有书籍”,在Vue组件中具有“编辑”视图,我试图发出axios请求以获取指定ID的所有当前值,但是这使我在日志上抛出此错误

.header {
    background-color: red;
    grid-area: header;

}

.sidebar {
    background-color: blue;
    grid-area: sidebar;

}

.content {
    background-color: yellow;
    grid-area: content;
}

.footer {
    background-color: green;
    grid-area: footer;
}

main {
    display: grid;
    grid-template-columns: 50px 1fr 1fr 1fr 1fr;
    grid-template-rows: 100px 1fr 100px;
    grid-template-areas: "sidebar  header  header  header  header"
                         "sidebar  content content content content"
                         "footer footer footer footer footer";
}

这是我所有的书laravel刀片文件

[2019-12-08 12:13:22] local.ERROR: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type integer: "edit" (SQL: select * from "sjl_libros" where "isbn" = edit limit 1) {"userId":1,"exception":"[object] (Illuminate\\Database\\QueryException(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type integer: \"edit\" (SQL: select * from \"sjl_libros\" where \"isbn\" = edit limit 1) at C:\\Users\\Hyper\\Documents\\GitHub\\SBD1-Reading-club\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php:665)
[stacktrace]

这是我的控制人

<table class="table">
    <thead>
    <tr>
    <th class="text-center">Original Title</th>
    <th class="text-center">Publishing Group</th>
    <th class="text-center">Action</th>
    </tr>
</thead>
   <tbody>
   @foreach($books as $book)
   <tr>
       <td class="text-center">{{$book->titulo_ori}}</td>
       <td class="text-center">{{$book->editorial}}</td>
       <td class="td-actions text-center">
       <b-link href="{{ route('books.show',$book->isbn) }}" type="button" rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="Visualizar" class="btn btn-info"><i class="material-icons">remove_red_eye</i>
       </b-link>
       <b-link href="/books/{{$book->isbn}}/edit" type="button" rel="tooltip" data-toggle="tooltip" data-placement="bottom" title="Modificar" class="btn btn-success"><i class="material-icons">edit</i>
       </b-link>
      <div class="d-inline-block">
      {!! Form::open(['route'=> ['books.destroy', $book->isbn], 'method'=>'DELETE']) !!}
      {!! Form::button('<i class="material-icons">close</i>', ['type' => 'submit','class' => 'btn btn-danger']) !!}
      {!! Form::close() !!}
 </div>
  </td>
  </tr>
@endforeach

</tbody>
</table>

这是我的要求

public function edit(Request $request, Book $book)
    {   

        if($request->ajax()){
            $edit = DB::select( DB::raw("SELECT nom FROM sjl_editoriales WHERE id = '$book->id_edit'"))[0];
            $book->editorial = $edit->nom;

            $editoriales = DB::select( DB::raw("SELECT id, nom FROM sjl_editoriales"));

            return Response::json(array('data'=>$book,'editoriales'=>$editoriales));
        }
        else{
            return view('books.edit');
        }
    }

为什么会这样,我该如何解决?

0 个答案:

没有答案