Achala Dissanayake Achala Dissanayake - 5 months ago 32
MySQL Question

how to get inputs from a html form and store in the database in Laravel 5.2?

Can someone explain it step by step. Videos and tutorials found on web do not give a clear understanding about the procedure.

Answer

Create an object of the model class related to the data table eg : //creating a patient object to add a row to patients table

    $patient = new Patient();

Assign the values //assign relavant values related to a patient in patients table

    $patient->user_id = $user->id;
    $patient->firstName = $request['firstName'];
    $patient->lastName = $request['lastName'];
    $patient->gender = $request['gender'];
    $patient->gender = 'male';
    $patient->birthYear = $request['birthYear'];
    $patient->telephoneNo = $request['contactNo'];
    $patient->locale = $request['locale'];
    $patient->bloodType = $request['bloodGroup'];

Call save() method. //this will save a patient's record to the patients table

    $patient->save();
Comments