Number of controllers for multipage survey questionnaire Laravel / PHP - php

I am building a survey questionnaire in PHP using Laravel and there are five HTML pages (one for each section). Do I need to create separate controllers for each HTML page in order to process the data to the database?

Usually it is good to stick to the different logic-different controller.
As you provided very small amount of info, its not clear what you want to do, but based on the info I understand, you’ll just need one controller and one method for all the html pages.

Related

multiple controllers for one view php mvc design

I am very new to MVC.
I just finished reading a book and am trying to implement what I have learned, but I am stuck. In the book and some other explanations I have read online, it's always one controller for one view, like navigation view being controlled by its controller, login form controlled by its own controller.
But I have a header with couple of navigation links, and a search form. Do I separate navigation from searching or assume searching is part of navigation and just control them all in one controller?
First of all, you seem to have the impression that "template" and "view" is the same thing. It's wrong. A properly done view will juggle multiple templates and choose which combination to use based on the current state of the model layer.
As for your navigation & search thing ... well ... it's confusing. Each link in navigation would point to either a different controller entirely or a different methods of controller. And search query would definitely be submitted to a separate controller/view pair.
The navigation+search is just a template, that is used in multiple views as part of the complete response.

Share form data with another view in Laravel

I have a Laravel Application with some Angular JS, I'm using Laravel to do the routing as it's easier for my team (who rarely use JS at all) to understand later, I have a route that allows me to create briefings, this is done first by selecting some options (which are passed as an array to the Laravel Controller and sent to the view) and then generating the project
Now, when I have the project generated I'm taken to another view with a sidebar, this sidebar allows me to change to different subsections of the briefing, for instance, there's a section for Development and another for Design.
These are different routes in Laravel that take the user to different forms, the problem is that these forms need to generate conditionally with blade's #if command and in order to do that, I need to get the original options array from my generator view into all of these other views.
How can this be achieved in Laravel 5.2?
Did you try to use SESSION ?
On submit a form, use SESSION to save some data that you need and you can easily find it at any moment with SESSION.

When using MVC in PHP,Should 1 Controller be able to load a entire dynamic user profile?

Im almost scared to ask questions around here these days because I useually get flammed on and told my question is dumb, but here it goes anyways...
Im new to MVCs and im starting to get the hang of them, but one thing im unsure about is if 1 controller is suppose to load a entire profile that has multiple components (i.e a notification beacon, a friend feed, a list of friends that displays thumbnails , a place to post statuses ect...)for the purposes of this post assume im asking if alll the loading for a entire facebook profile should be done in one controller?
Or do i separate each dynamic component into its own MVC and then glue them all together in one main controller or....?
another idea i had was that maybe u do separate each component , but instead of having one main controller you call them as needed in the index.
You could use one controller for the Profile (using your example) and have multiple models fetch and process all the data you need to show. This way even a big page can result in an easy to understand controller that is not so big.

MVC Right separation for functional component

I am building a Web application that allow people to subscribe to certain classes which are divided by semesters.
In one of my interface I have a list of all activities that act as a summary in the backend interface. I was looking to group them by semester and browse through a sequential navigation.
My problem is, where should I put my code since I want it to be easy to maintain and I want to respect the right MVC structure.
Here are my Ideas:
Get the param value in the controller, get the previous and next semester through an
action helper, send the data to the view and then display it
or
Get the param value in the controller, sent it to the view, let the view (through a
view helper) find the previous and next semester and then display it
I have a class that is able to find the semesters through calculation (so it's not in my models)
The first option. Your question is unclear to me, but your first option sounds the closest to what I would do.

PHP : inheritance logical (extends)

This may sound as a non related coding question but it's directly related :
The facts: I've developped a website (with symfony) which allows players to search for a team (like a job board). It makes one module only.
The problems I want the website to be even more accurate and make a custom form for each players depending on the game (for example, for those who play "league of legends" they'll have 3 more informations to fill up....)
The solutions?
One module per game (example: http://pastie.org/private/cl48jsrjreukyjmj7jrk8a).
I'm currently developping 1 module per game in order to take in consideration the specific criteria for specific games.
Advantages :
The player enters the informations in relation with his game and does not see/interact the other criteria
Disavantages:
90% of the code are the same between each modules. It takes more time.
Inheritance
I never played with that before so i don't know if it's possible in my case to stick with 1 module for the entire game collection AND taking in consideration the specific criterias for games. In that case it would mean to have 1 template per game and displaying the right template with the right accessors like
($this->getCV()->getPseudo(); / $this->getCV()->getGame()->getSpecificCriteria1();)
If I have read your question correctly, you want to show additional fields for each specific game.
Solution 1
Create a 2 form process. After your first form, you could redirect the user to a second form which depends on their answers. To do this, in your first form, use a redirect to send the user to a game-specific second form.
Solution 2
Pass the name of the game to the template and show a customised partial for the extra form fields. For this you will need a Url with a game parameter like this:
www.example.com/form/show/:game_identifier
Then in your action, read the parameter and pass it to your template.
In the template, show a partial dependant on the game that was passed through. So only show the extra fields if a specific game was chosen before hand.
There are further ways to accomplish this but these 2 sprung to mind first.

Categories