Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Chris Berthe
2012-06-25 13:11:54 -04:00
23 changed files with 320 additions and 21 deletions

View File

@@ -278,7 +278,7 @@ class Blade {
*/
protected static function compile_structure_closings($value)
{
$pattern = '/(\s*)@(endif|endforeach|endfor|endwhile)(\s*)/';
$pattern = '/(\s*)@(endif|endforeach|endfor|endwhile|break)(\s*)/';
return preg_replace($pattern, '$1<?php $2; ?>$3', $value);
}

View File

@@ -194,7 +194,7 @@ class Connection {
return $statement->rowCount();
}
// For insert statements that use the "returning" clause, which is allowed
// by databsae systems such as Postgres, we need to actually return the
// by database systems such as Postgres, we need to actually return the
// real query result so the consumer can get the ID.
elseif (stripos($sql, 'insert') === 0 and stripos($sql, 'returning') !== false)
{

View File

@@ -253,7 +253,27 @@ abstract class Model {
*/
public function _with($includes)
{
$this->includes = (array) $includes;
$includes = (array) $includes;
$all_includes = array();
foreach($includes as $include)
{
$nested = explode('.', $include);
$inc = array();
foreach($nested as $relation)
{
$inc[] = $relation;
$all_includes[] = implode('.', $inc);
}
}
//remove duplicates and reset the array keys.
$this->includes = array_values(array_unique($all_includes));
return $this;
}

View File

@@ -21,7 +21,7 @@ abstract class Grammar extends \Laravel\Database\Grammar {
// command is being executed and the referenced table are wrapped.
$table = $this->wrap($table);
$on = $this->wrap($command->on);
$on = $this->wrap_table($command->on);
// Next we need to columnize both the command table's columns as well as
// the columns referenced by the foreign key. We'll cast the referenced

View File

@@ -418,4 +418,4 @@ class MySQL extends Grammar {
return 'BLOB';
}
}
}

View File

@@ -393,9 +393,7 @@ class Table {
{
$parameters = array_merge(compact('type'), $parameters);
$this->commands[] = new Fluent($parameters);
return end($this->commands);
return $this->commands[] = new Fluent($parameters);
}
/**
@@ -409,9 +407,7 @@ class Table {
{
$parameters = array_merge(compact('type'), $parameters);
$this->columns[] = new Fluent($parameters);
return end($this->columns);
return $this->columns[] = new Fluent($parameters);
}
}

View File

@@ -63,7 +63,7 @@ It is common to limit access to certain routes only to logged in users. In Larav
To protect a route, simply attach the **auth** filter:
Route::get('admin', array('before' => 'auth', function() {});
Route::get('admin', array('before' => 'auth', function() {}));
> **Note:** You are free to edit the **auth** filter however you like. A default implementation is located in **application/routes.php**.

View File

@@ -4,6 +4,7 @@
- [Installation & Setup](/docs/install)
- [Requirements](/docs/install#requirements)
- [Installation](/docs/install#installation)
- [Server Configuration: Why Public?](/docs/install#server-configuration)
- [Basic Configuration](/docs/install#basic-configuration)
- [Environments](/docs/install#environments)
- [Cleaner URLs](/docs/install#cleaner-urls)

View File

@@ -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:
$user = User::where('email', '=', $email)->first();

View File

@@ -145,4 +145,10 @@ Sometimes you may wish to merge or replace the current input. Here's how:
#### Replacing the entire input array with new data:
Input::merge(array('doctor' => 'Bones', 'captain' => 'Kirk'));
Input::merge(array('doctor' => 'Bones', 'captain' => 'Kirk'));
## Clearing Input
To clear all input data for the current request, using the `clear()` method, for example:
Input::clear();

View File

@@ -4,6 +4,7 @@
- [Requirements](#requirements)
- [Installation](#installation)
- [Server Configuration: Why Public?](#server-configuration)
- [Basic Configuration](#basic-configuration)
- [Environments](#environments)
- [Cleaner URLs](#cleaner-urls)
@@ -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.
<a name="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).
<a name="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!

View File

@@ -12,7 +12,7 @@
<a name="the-basics"></a>
## The Basics
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:
#### Get an array of data you want to validate:

View File

@@ -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:
@layout('master')

View File

@@ -427,7 +427,7 @@ class Form {
$html[] = static::option($value, $display, $selected);
}
return '<optgroup label="'.HTML::entities($label).'">'.implode('', $html).'</option>';
return '<optgroup label="'.HTML::entities($label).'">'.implode('', $html).'</optgroup>';
}
/**

View File

@@ -287,4 +287,13 @@ class Input {
Request::foundation()->request->replace($input);
}
/**
* Clear the input for the current request.
* @return void
*/
public static function clear()
{
Request::foundation()->request->replace(array());
}
}

View File

@@ -102,7 +102,8 @@ class Request {
*/
public static function ip($default = '0.0.0.0')
{
return value(static::foundation()->getClientIp(), $default);
$client_ip = static::foundation()->getClientIp();
return $client_ip === NULL ? $default : $client_ip;
}
/**

View File

@@ -1,4 +1,4 @@
<?php namespace Laravel;
<?php namespace Laravel; use Closure;
class Session {

View File

@@ -118,6 +118,11 @@ class View implements ArrayAccess {
*/
public static function exists($view, $return_path = false)
{
if (starts_with($view, 'name: ') and array_key_exists($name = substr($view, 6), static::$names))
{
$view = static::$names[$name];
}
list($bundle, $view) = Bundle::parse($view);
$view = str_replace('.', '/', $view);