0

Array to string conversion (SQL: insert into RegisterStudent (LRN, dateOfBirth, sex, updated_at, created_at) values (1234, 1996-02-10, Female, 2017-10-26 05:30:32, 2017-10-26 05:30:32))

enter image description here

StudentController store content

public function store(Request $request){

     //validation
    $this->validate($request, [
        'LRN' => 'required|max:100',
    ]);

    $student = New Student;
    $student->LRN = $request->input('LRN');
    $student->dateOfBirth = $request->input('dateOfBirth');
    $student->sex = $request->input('sex');

    $student->save();

    return redirect()->back();
}
2
  • You are sending LRN and sex as an array. Show your html code Commented Oct 26, 2017 at 5:45
  • Lois Arce, check out madalinivascu's answer. It will solve the issue. Commented Oct 26, 2017 at 5:57

1 Answer 1

1

Change the following:

$student->sex = $request->input('sex')[0];

the input seems to be a array so you need the value at [0] or remove the [] in your input name to use in php $request->input('sex')

Sign up to request clarification or add additional context in comments.

2 Comments

How could you decide that its sex but not any other field?
@HimanshuUpadhyay if you look in the screenshot,in the white list the second item you can see array('Female')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.