@@ -65,7 +65,7 @@ Need to retrieve an entire table? Just use the static **all** method:
echo $user->email;
}
Of course, retrieving an entire table isn't very helpful. Thankfully, **every method that is available through the fluent query builder is available in Eloquent**. Just begin querying your model with a static call to one of the [query builder](/docs/database/query) methods, and execute the query using the **get** or **first** method. The get method will return an array of models, while the first method will return a single model:
Of course, retrieving an entire table isn't very helpful. Thankfully, **every method that is available through the fluent query builder is available in Eloquent**. Just begin querying your model with a static call to one of the [query builder](/docs/database/fluent) methods, and execute the query using the **get** or **first** method. The get method will return an array of models, while the first method will return a single model:
@@ -37,8 +38,30 @@ Installing the following goodies will help you take full advantage of Laravel, b
If you are having problems installing, try the following:
- Make sure the **public** directory is the document root of your web server.
- Make sure the **public** directory is the document root of your web server. (see: Server Configuration below)
- If you are using mod_rewrite, set the **index** option in **application/config/application.php** to an empty string.
- Verify that your storage folder and the folders within in are writable by your web server.
<aname="server-configuration"></a>
## Server Configuration: Why Public?
Like most web-development frameworks, Laravel is designed to protect your application code, bundles, and local storage by placing only files that are necessarily public in the web server's DocumentRoot. This prevents some types of server misconfiguration from making your code (including database passwords and other configuration data) accessible through the web server. It's best to be safe.
In this example let's imagine that we installed Laravel to the directory **/Users/JonSnow/Sites/MySite**.
A very basic example of an Apache VirtualHost configuration for MySite might look like this.
<VirtualHost *:80>
DocumentRoot /Users/JonSnow/Sites/MySite/public
ServerName mysite.local
</VirtualHost>
Notice that while we installed to **/Users/JonSnow/Sites/MySite** our DocumentRoot points to **/Users/JonSnow/Sites/MySite/public**.
Pointing the DocumentRoot to the public folder is a commonly used best-practice. However, you may need to use Laravel on a host that does not allow you to update your DocumentRoot. This is possible, but before resigning to this option it's best to contact your host and verify that you are unable to change your DocumentRoot to increase the security of your application.
More information about how to use the public folder can be found on the [Laravel Forums](http://forums.laravel.com/viewtopic.php?pid=10023#p10023).
<aname="basic-configuration"></a>
## Basic Configuration
...
...
@@ -70,7 +93,7 @@ Next, create an **application/config/local** directory. Any files and options yo
);
In this example, the local **URL** option will override the **URL** option in **application/config/application.php**. Notice that you only need to specify the options you wish to override.
In this example, the local **URL** option will override the **URL** option in **application/config/application.php**. Notice that you only need to specify the options you wish to override.
Isn't it easy? Of course, you are free to create as many environments as you wish!
Almost every interactive web application needs to validate data. For instance, a registration form probably requires the password to be confirmed. Maybe the e-mail address must be unique. Validating data can be a cumbersome process. Thankfully, it isn't in Laravel. The Validator class provides as awesome array of validation helpers to make validating your data a breeze. Let's walk through an example:
Almost every interactive web application needs to validate data. For instance, a registration form probably requires the password to be confirmed. Maybe the e-mail address must be unique. Validating data can be a cumbersome process. Thankfully, it isn't in Laravel. The Validator class provides an awesome array of validation helpers to make validating your data a breeze. Let's walk through an example:
@@ -164,6 +164,8 @@ Great! Now, we can simply return the "profile" view from our route:
The profile view will automatically use the "master" template thanks to Blade's **@layout** expression.
**Important:** The **@layout** call must always be on the very first line of the file, with no leading whitespaces or newline breaks.
Sometimes you may want to only append to a section of a layout rather than overwrite it. For example, consider the navigation list in our "master" layout. Let's assume we just want to append a new list item. Here's how to do it: