irankhosravi
1 year ago

localStorage in laravel with javascript not working.

Posted 1 year ago by irankhosravi

How to define when save a variable in localStorage to send controller.

    var school_id = {school_id: data_school.id};
    localStorage.setItem("new_school_id", school_id );

For example I defined a variable new_school_id.

Now how to defined for save in controller.

   $requisition->school_id = intval($request->new_school_id);

I get this error.

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (prj_tvto.requisitions, CONSTRAINT requisitions_school_id_foreign FOREIGN KEY (school_id) REFERENCES schools (id)) (SQL: insert into requisitions (user_id, school_id, type, date, status, approved, updated_at, created_at) values (1, 0, 2, 0, 0, 0, 2018-09-16 09:33:56, 2018-09-16 09:33:56))

Please sign in or create an account to participate in this conversation.