php - Issue with Form model binding in Laravel 5.4 -


this doesn't occur when i'm form model binding in laravel, reason, every time pull binded form, i'm getting exact same record.

{!! form::model($contact, ['method'=>'put', 'route'=>['contact.update', $contact->id]]) !!} {!! form::label('firstname', 'first name:') !!} {!! form::text('firstname', null, ['class'=>'form-control']) !!} {!! form::label('lastname', 'last name:') !!} {!! form::text('lastname', null, ['class'=>'form-control']) !!} {!! form::label('email', 'email:') !!} {!! form::text('email', null, ['class'=>'form-control']) !!} {!! form::label('address', 'address:') !!} {!! form::text('address', null, ['class'=>'form-control']) !!} {!! form::label('phone_number', 'phone:') !!} {!! form::text('phone_number', null, ['class'=>'form-control']) !!} {!! form::submit('update contact', ['class'=>'btn btn-primary']) !!} {!! form::button('close', ['class'=>'btn btn-default', 'data-dismiss'=>'modal']) !!} {!! form::close() !!} 

controller:

public function index() {     $user = auth::user();     $contacts = $user->contacts()->get();     return view('contacts.index', compact('contacts','user')); } 

when click button, form popping modal

<button class="btn btn-default editcontact" data-toggle="modal" data-target="#editmodal">edit contact</button> 

i've used same format before , gives me different records each click. reason every record click on display update form, registers same record every time. ideas on how fix this?

i think can try :

public function index() {     $user = auth::user();     $contacts = contacts::where('user_id',$user->id)->first();     return view('contacts.index', compact('contacts','user')); } 

hope !!!


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -