So a pretty useful feature to have in an application that lets users authenticate is to also create
an account.
Now we don't have this feature yet, and in the next couple of videos I'd like us to create it.
So it would be actually pretty similar to the login feature, and it would be implemented in a similar
way.
So we already have controllers in our framework which does render individual pages or just handle logic
of certain URLs which we can define inside routes.
So as you see inside the auth controller which is responsible for signing users in, we typically have
an action called create that displays a form.
And that's everything it does.
It displays the form and the form is submitted into another action of that controller.
Typically we call this one store.
This is the way we organize resources inside a single controller, so this one is responsible for signing
users in.
Nothing else.
If we create a similar one that is responsible for creating accounts, we can reuse the same schema
of thinking.
So we can have a create action that displays a registration form, and then a store action that can
create a user if some of the conditions are met, which can be that the email doesn't exist in the database,
and that the password and repeated passwords are the same.
For that, we can even reuse the form that we already have.
I mean the HTML of the sign in form.
So without further ado, let's get started.
And let's go ahead and start implementing the registration logic.
So to make matters quicker, let's just copy and paste this auth controller because we're going to reuse
some concepts from it.
So I'm going to paste it and I'm going to call it user controller as actually we're going to be working
with the user model here.
So I think it fits.
Now let me jump to a concept that I've mentioned before.
So I really think that there are a lot of great concepts in the Laravel framework.
One of those is to create so-called resource controllers, which essentially means that you are assuming
that when you are creating a controller class, which as you see, we are doing all the time, every
single controller should just strive to work with one resource.
What I mean by that, and what Laravel means by that is, for example, in this, uh, that we see right
on the screen, we would like to work with photos.
So we create a controller that can list a Photos, create a new one or display a form, store it into
the database, display one photo, edit it, update it, and destroyed.
Edit means display the form.
So by sticking to this simple convention, we just make things simpler for ourselves and for other developers
that might be working on the same project in the future.
Because you never, ever would have to think about the action names.
You would not have to think what someone meant and why.
This action is created and called the way it is, because you would be expecting that you only see specific
action names like create, and you instantly know what it's going to do.
It's going to display a form.
When you see a star action name, you know that it will store something in some kind of a database.
And then you know that this controller is about users.
So then you also instantly know it's going to store some user model inside the database table.
I think that such conventions are super strong, and they just make you stop thinking about things that
aren't important and focus on the most important things, which is actually building the app.
So let's follow this path, and let's use this convention to quickly create the user controller for
user registration.
Now the part of the convention is also to call the folder that contains the views same as the controller.
That's why I'm going to create a new folder and I will call it user.
Inside it we need a form so we can quickly copy and paste this create form, because the registration
form will have very similar fields to the login one.
Now let's make sure that here I am rendering the user create form.
And then let's also jump to routes and register some new routes.
So we need two routes to display the registration form.
And to actually handle the registration.
Let me add them in the general routes and I might call it register.
And the same path would be used for the post action because it contains different verb.
So basically they are different.
Now that's a user controller not an orphan.
And there we have it.
We should have this controller working.
At least it should display something.
So let's make sure that we have this create form.
That's for the registration.
And now let me call it maybe create count or maybe just register.
Let's keep it simple.
Okay, now I should be able to jump to our page.
And if I type the URL manually, let it be Register.
Now I'm seeing the registration form.
Now we're gonna work from here because we need to add some more fields.
When you sign in, you only supply the email and password.
But when you register, you also have to provide your full name and you need to make sure you are repeating
the password, and that is that it is also the same as the original password.
So we're going to work on this in the next video.
For now we've just created another controller and well another template and explained a little the way
we're gonna work with this project.