I'm still learning Laravel, as what I'm trying to accomplish at the moment is the following logic:
-An User submits a form-> The form input is saved into DB, and is 'sent' to another User who can then validate it->I save into the DB if the state is validated or not, and inform the User who sent the form.
I know this is not too hard, but I'm doing it as I learn Laravel, so I'm coming up with a few 'problems'.
First of all, I do have quite a lot of forms, and I did get the Post logic working. At the moment I'm not working with the Database yet, so I tested the Forms with SESSION, to make sure the data was being saved.
So my first question is: is it best practice in this case to keep all form logic into one Controller? Like the following(this is working with two different forms) (session is there only for testing purposes)
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PostController extends Controller
{
public function geralSuggest(Request $request)
{
$name = $request->input('obs');
return redirect('sugestoes');
}
public function GD(Request $request)
{
session_start();
$name = $request->input('nome');
$cc = $request->input('cartao');
$array = array ($name, $cc);
$_SESSION["testPostSection"] = $array;
return redirect('declaracaogd');
}
}
Secondly, I have some forms where the user can add inputs. Lets say one input is for the name, and the user has a button that when he clicks he adds another name input, so he can input many names at once. This is done by Javascript on my side. What I'm wondering is how will I save this inputs, since I 'don't know' how many "names" the user will be submitting. I was thinking a for or foreach loop, where I would check with "isset", but I'm not sure if it will work. I will be testing this when I get to it regardless, and I'm sure I'll figure it out, but if you know a good logic for this and could point me in the right path, it would be appreciated.
Lastly, about my general logic, for User validation, from what I read on Laravel documentation, I think Events will be what makes the trigger to 'warn' the second User that he needs to validate a form, is that correct?
I'm sorry if I'm asking "too much at once" or if these are very basic questions. I just wanted to make sure that I'm going in the right direction.
Thanks a ton in advance!