Laravel 6 Beginner - e18 - Final Project Part 2 (Questionnaire/Survey App)
HTML-код
- Опубликовано: 1 окт 2024
- For a final project on this course, let's build an App for creating questionnaires (surveys). In part 2, we are answering one of the most frequent questions that I get, how to save from 1 form to multiple tables at once.
For the best experience, follow along in our interactive school at www.coderstape...
DigitalOcean Referral
m.do.co/c/7dce...
About This Course
If you have been looking to learn Laravel, there hasn't been a better time. The framework reached an important point in its life, with the release of Laravel 6. There has never been more demand for Laravel developers than now. In this series, we are going to get you started in your path to becoming a Laravel Artisan. Let's get right to it!
You deserve millions of subscribers
Not because im not following this series it means that i dont want your content.. It means that because of your previous tutorial. I can now do some application alone :) Thank you so much Sir :)
i guess it's pretty off topic but does anyone know of a good place to watch newly released series online ?
@Caspian Fox Try FlixZone. You can find it on google =)
@Armani Davis Yea, I've been watching on flixzone for years myself :)
@Armani Davis Thank you, I signed up and it seems like they got a lot of movies there :) Appreciate it!
@Caspian Fox no problem xD
passing from form as:
$questions['question'] = 'ding';
$answers[]['answers'] = 'first';
$answers[]['answers'] = 'second';
$answers[]['answers'] = 'third';
$answers[]['answers'] = 'fourth';
which results in:
//questions
Array
(
[question] => ding
)
// answers
Array
(
[0] => Array
(
[answers] => first
)
[1] => Array
(
[answers] => second
)
[2] => Array
(
[answers] => third
)
[3] => Array
(
[answers] => fourth
)
)
Can you do a video with laravel and ajax combined??
please make a video about vue + laravel from scratch
Great video ever, it has lot of content....
This one really bugs me. @06:49 you are using the following in the url {{ $questionnaire->id }} - and this gives me an error under Laravel v8.40.0 (PHP v7.3.5). Now when I switch and use only one curly brace, the error goes away and the site is just working fine. I mean like this: { $questionnaire->id }. What did I miss...?
laravel version
Brilliant Tutorial.
I do have 2 questions:
Why not used short named routes instead?
For the question input in the form, why making it an array, why not simply name it to question instead of question[question]?
Using routes because this is a beginner level and I want it to be obvious what the route is. Named routes are not obvious where they’re going.
You could use question only but then you would have to wrap it in an array with the key of question or do something like Arr::only(). Give it a try and you’ll see what I mean.
@@CodersTape Thanks dear. Got the idea.
@@CodersTape Why do we need to wrap question in an array when there is only one question. In the former part of the playlist when we created service we just needed its name and we didn't create an array to store it in database. Please Explain.
@@itsumarejaz to make storing data easier and cleaner to code, as the array consists of respective table (i.e. ['question'] for Question model) for storing data.
interesting but i see that i have to slow down my pace as its beginning to be deep a bit by bit. Good work Coder'sTape....capital 'C' for controller kkkk
Soo.. input name in blades is a value passed from migration tables or even whole schemas (i am about schema named "answers")? Am i right?
If you follow that pattern than it certainly makes writing the code much easier.
@@CodersTape yup, I see it's very helpful. Thanks man!
Is there a way to add choices as we need not only 4 choices🙄🤔
i have some trouble with required answer field when i submit form even though i put value all field its always required?
at 19:33 when i dd($data) the answer not show? how i fixed it. even the views has the same code
what I miss?? I am getting Integrity constraint violation: 1048 Column 'questionnaire_id' cannot be null error
Check your relationships maybe?
same problem
If anyone knows a fix for this error please reply, I need to get this fixed ASAP.
nice video victor bro !! love you
Thank you so much. I'm a big fan of yours 😉😁
I do have a question. How can we perform an update in this questions table along with answers?
18:54 i don't get a blank page. Why? My questionare view look like array 15:47 can you help me ?
Why don't you create a paid Udemy course?!
e.g: The complete laravel handbook
Thank you sir,
how can i solve my "Call to a member function create() on null "error?
I got this error too. How did you solve this?
@@richardbernisca1427 Maybe u can check the defined relationship on each model, make sure it was correct with have "return" on it. Just follow the video exactly. should be correct
Amazing channel!! Can u build wordpress clone?
Really awesome tutorial. But I have a question that what if I want to update in has many relationship. I couldn't find any method for update. Can you help please. Thanks.
Hello Sir
plz make a big project on laravel 6 like you had made a tutorial dummy instagram project on freecodegram.
Thank you
In this video you write for your self. a lot of explanations missed
This is quite wonderful . This perhaps could be considered as one of the options to implement a double entry accounting system with nested account codes.
Thanks for the videos, you're a great teacher :) Only have a one question... How I save one image using laravel storage? Already create variable question[image] in the store method, but when push the image, dd show me "Null"... Help :(
Sorry for my bad english.
Make sure that your form has enctype="multipart/form-data"
this series is very interesting, like the explanation, now
Why not make an invoice project?
Im getting this error : "Call to a member function create() on null"
I don't know the exact your language but, everything is beautiful.
Very nice video tutorial.
Тест
thanks dude but Zoom in a little :)
Are you planning to do more advanced laravel tutorials in the future? :)
17:01 the validation are not working. i left the form empty and hit submit, yes its not going anywhere its just refreshing the page. but its not showing any error message. i mstuck here
i solved it by adding ' @error('question.question') is-invalid @enderroron ' the input class. how could you do it without that ?
when i am trying to save the answers give this error Undefined index
Undefined index: 'answers', right?
check your name attribute in your blade file. Or try dd() to figure it out what's wrong.
Sorry if this has been answered before. I'm following along the course but here I stuck with one question which is Why we need to make an array of question as we know there are can only be one question. I understand the need of array for answers as there can be four possible answers. Why do we need an array for question?
Because we’re trying to encapsulate the question form fields. Presumably there could be multiple form elements inside and we just want a “grouping” of question fields.
@@CodersTape but Sir there is only one question form "field" not multiple question form "fields".
So the reason I understood for creating an array for single question is that as we need to store data in two different tables i.e. questions and answers while hitting a single store method in QuestionController and we are passing data through $data variable which contains an associative array with two keys "question and answers" which further contain associative array of "question" and "answer" respectively. We passed $data['question'] in create() function which means whatever value $data['question'] has if it is similar to the column name of the respective table, a new record in that table will be created. As $data['question'] contains a sub-array with $key "question" which is similar to the column name in questions table, so boom, it will add new entry to questions table. Same goes for the array of answers. So it makes sense to pass $data['answers']. Note: If the $key names are similar to the column name in database then it is easier to store data in laravel.
Thanks a lot, your best practices are top tier
Glad you like them!