Jump to content
php.lv forumi

Sil Vestrs

Reģistrētie lietotāji
  • Content count

    1
  • Joined

  • Last visited

About Sil Vestrs

  • Rank
    Māceklis
  1. Sveiki, Jau kādu laiku mēģinu palaist edit post funciju izmantojot bootsrap modal'u. Varbūt kāds var ieraudzīt šeit problēmu un palīdzēt to atrisināt.... Modal izsaukšanas poga: <a href="#" data-toggle="modal" data-target="#editPost" class="edit">Edit</a> Modal: <div class="modal fade" tabindex="-1" role="dialog" id="editPost"> <div class="modal-dialog"> <form action="{{ route('editPost') }}" method="post"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Edit Post</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="modal-body"> <form> <div class="form-group"> <label for="post-body">Edit the post</label> <article class="post" data-postid="{{ $post->id }}"> <textarea class="form-control" name="body" id="editPost" rows="5">{{ $post->body }}</textarea> </article> </div> </form> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary">Save changes</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <input type="hidden" value="{{ Session::token() }}" name="_token"> </div> </div> </form> </div> </div> P.S- tāpatās $post->body man attēlo tikai 1. postu nevis konrētā- uz kura tiek nospiesta edit poga. Controllers: public function postEditPost(Request $request) { $this->validate($request,[ 'body' => 'required|max:1000' ]); $post = Post::find($request['postId']); $post->body = $request['body']; $post->update(); return response()->json(['message' => 'Post edited'],200); } } Route: Route::post('/editpost',[ 'uses' => 'PostController@postEditPost', 'as' => 'editPost', 'middleware' => 'auth' ]); Saņemu erroru: $post->body = $request['body']; "Creating default object from empty value" Please help!
×