Skip to content
Advertisement

Laravel (How do I add data to database)

Here’s my code that shows projects assigned to a user.

HomeController

JavaScript

home.blade.php

JavaScript

ProjectController that show issues within the project.

JavaScript

route:

JavaScript

issues.blade.php

JavaScript

I made a button in the issues page that shows a modal that has a form for adding issues for the selected project. Can you help me with this? On how to do that?

Advertisement

Answer

Let’s imagine you have project controller like this.

JavaScript

You don’ have to pass issues into blade. You can print it easily there.

Your blade

JavaScript

Your form in your popup in blade

JavaScript

So what we did. You pasted the project id into form in hidden input. So now, after form submit you have in your backend input called project_id in your request.

In your issue controller

JavaScript

Probably you have column project_id in your issues. So you can save it with $issue->associate($project_id). That’s just an example!!

I don’t know other fields you need to save with your issue, so I cannot help you more. I think you have got everything you needed to make a draft. 🙂

GL

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement