vendredi 7 juin 2019

How to save records in database?

I'm writing and reading some records from my database using Laravel. I need to add emergency contact to user's profile.

Here is the function in PatientController:

public function addEmergencyContact(){
    $contact = PazientiContatti::create([
        'id_paziente' => Pazienti::where('id_utente', Auth::id())->first()->id_paziente,
        'contatto_nominativo' => Input::get('modcontemerg_add'),
        'contatto_telefono' => Input::get('modtelcontemerg_add'),
        'id_contatto_tipologia' => '10',
    ]);


    $contact->save();
    return Redirect::back()->with('contact_added');
}

Here is the form's inputs in a view:

<input type="text" name="modcontemerg_add" id="modcontemerg_add" class="form-control col-lg-6" value=""/>

<input type="text" name="modtelcontemerg_add" id="modtelcontemerg_add" class="form-control col-lg-6" value=""/>

Here is how i read contacts:

@foreach ($contacts as $contact)
@if($contact->id_contatto_tipologia == 10)
<tr>
    <td></td>
<td></td>
<td>
    <input type="hidden" name="id_contact" id="id_contact" value="">
        <button type="submit" class="removeContact buttonDelete btn btn-default btn-danger" ><i class="icon-remove"></i></button>
    </td>
<tr>
@endif
@endforeach

The output should be
- Name: try
- Contact: 333

Actual output:
- Name : eyJpdiI6IkVyUm9zekk4M2YwMVwvS0U3Mzdmb...
- Contact: eyJkosmCNskDNs85Sjcnscsajcn...

How can i fix it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire