Laravel Starter - PHP User Group (Myanmar)
Laravel Starter - PHP User Group (Myanmar)
Laravel Starter - PHP User Group (Myanmar)
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Laravel</strong> <strong>Starter</strong><br />
Go ahead and navigate to http://myfirst.dev/test in your browser. You should see the<br />
confirmation message that the user has been saved to the database.<br />
Now, take a look at the contents of your database's users table. You will see a new record filled<br />
with our data. Notice that the timestamps fields have been automatically pre-populated for<br />
you. It's that easy to create new database records with Eloquent!<br />
Step 6 – The users controller<br />
Now it's time for us to create our first controller. You've already learned how we can route to a<br />
closure and you can use this method to make an entire web-application. So, what are controllers<br />
and why should we use them?<br />
Controllers are containers for methods that contain application logic related to a common<br />
domain. A domain is simply a categorization of purpose. In the context of our web application,<br />
we will be working solely with administrating user data. Therefore, our domain is users. Our<br />
users controller will contain the application logic that controls our application flow and delivers<br />
our database data to the view for formatting.<br />
Since controllers allow us to group logic, we can also apply configurations to a controller that will<br />
affect all of the methods inside it. We'll explore more of this concept later.<br />
Let's create the file application/controllers/users.php and fill it with our controller<br />
class' skeleton:<br />