From 115eb8d085515388f7de932feb52eea861ad65f0 Mon Sep 17 00:00:00 2001 From: Aaron Kuzemchak Date: Thu, 23 Feb 2012 20:08:12 -0500 Subject: [PATCH 01/22] Added shortcut method to load a designated route's response --- laravel/routing/route.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/laravel/routing/route.php b/laravel/routing/route.php index 97a8f524..6243d1e4 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -348,5 +348,17 @@ class Route { { Filter::register($name, $callback); } + + /** + * Calls the specified route and returns its response. + * + * @param string $method + * @param string $uri + * @return Response + */ + public static function load($method, $uri) + { + return Router::route(strtoupper($method), $uri)->call(); + } } \ No newline at end of file From 2c4d35e6a4bb5eecf119b8db9f9d8151e484eb5f Mon Sep 17 00:00:00 2001 From: Dayle Rees Date: Thu, 1 Mar 2012 12:12:39 +0000 Subject: [PATCH 02/22] allow File::cpdir() to fail (and return false) --- laravel/file.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/laravel/file.php b/laravel/file.php index 8d3cee74..b584d00d 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -183,7 +183,7 @@ class File { */ public static function mvdir($source, $destination, $options = fIterator::SKIP_DOTS) { - static::cpdir($source, $destination, true, $options); + return static::cpdir($source, $destination, true, $options); } /** @@ -197,7 +197,7 @@ class File { */ public static function cpdir($source, $destination, $delete = false, $options = fIterator::SKIP_DOTS) { - if ( ! is_dir($source)) return; + if ( ! is_dir($source)) return false; // First we need to create the destination directory if it doesn't // already exists. This directory hosts all of the assets we copy @@ -221,7 +221,7 @@ class File { { $path = $item->getRealPath(); - static::cpdir($path, $location, $delete, $options); + if (! static::cpdir($path, $location, $delete, $options)) return false; if ($delete) @rmdir($item->getRealPath()); } @@ -231,13 +231,15 @@ class File { // files with the same name. else { - copy($item->getRealPath(), $location); + if(! copy($item->getRealPath(), $location)) return false; if ($delete) @unlink($item->getRealPath()); } } if ($delete) rmdir($source); + + return true; } /** From 95ba416f3c8292574ec504fb0364f4593a12a23a Mon Sep 17 00:00:00 2001 From: Kyle Decot Date: Fri, 16 Mar 2012 13:35:15 -0400 Subject: [PATCH 03/22] Adds Form::register which allows Bundles (or anything for that matter) to register custom form inputs which then can be called like `Form::xxx` --- laravel/form.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/laravel/form.php b/laravel/form.php index 1fd97ca6..32aff7e4 100644 --- a/laravel/form.php +++ b/laravel/form.php @@ -8,6 +8,28 @@ class Form { * @var array */ protected static $labels = array(); + + /** + * The registered custom inputs + * + * @var array + */ + + protected static $inputs = array(); + + /** + * Dynamically handle calls to custom registered inputs. + */ + + public static function __callStatic($method, $parameters) + { + if (isset(static::$inputs[$method])) + { + return call_user_func_array(static::$inputs[$method], $parameters); + } + + throw new \Exception("Method [$method] does not exist."); + } /** * Open a HTML form. @@ -61,6 +83,19 @@ class Form { return ''.$append.PHP_EOL; } + + /** + * Registers a custom input + * + * @param string $name + * @param Closure $input + * @return void + */ + + public static function register($name, $input) + { + static::$inputs[$name] = $input; + } /** * Determine the appropriate request method to use for a form. From 1044367c1e3392ab6e9343f55b4fd8404e0e23f5 Mon Sep 17 00:00:00 2001 From: Anton Khodakivskiy Date: Mon, 19 Mar 2012 07:47:20 -0400 Subject: [PATCH 04/22] added default values to the signature of Query::left_join to allow closure-based join conditions --- laravel/database/query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/database/query.php b/laravel/database/query.php index d0503d6a..95ad17a6 100644 --- a/laravel/database/query.php +++ b/laravel/database/query.php @@ -182,7 +182,7 @@ class Query { * @param string $column2 * @return Query */ - public function left_join($table, $column1, $operator, $column2) + public function left_join($table, $column1, $operator = null, $column2 = null) { return $this->join($table, $column1, $operator, $column2, 'LEFT'); } From 88b006901364b2acd87453f909c98e0e20fbf4da Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 19 Mar 2012 23:32:38 -0500 Subject: [PATCH 05/22] Fixed typo --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index da5fb487..e05ef395 100644 --- a/readme.md +++ b/readme.md @@ -41,7 +41,7 @@ Laravel is a clean and classy framework for PHP web development. Freeing you fro Contributions are encouraged and welcome; however, please review the Developer Certificate of Origin in the "license.txt" file included in the repository. All commits must be signed off using the "-s" switch. - git commit -s -m "thie commit will be signed off automatically!" + git commit -s -m "this commit will be signed off automatically!" ### License From ce9f4f1db7c893a676289c5ec3745752b4ce7bd2 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 10:33:06 -0500 Subject: [PATCH 06/22] Added support for on_delete and on_cascade of foreign keys. --- laravel/database/schema/grammars/grammar.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/laravel/database/schema/grammars/grammar.php b/laravel/database/schema/grammars/grammar.php index ad0dfbcc..1d3390a1 100644 --- a/laravel/database/schema/grammars/grammar.php +++ b/laravel/database/schema/grammars/grammar.php @@ -32,7 +32,22 @@ abstract class Grammar extends \Laravel\Database\Grammar { $sql = "ALTER TABLE $table ADD CONSTRAINT $name "; - return $sql .= "FOREIGN KEY ($foreign) REFERENCES $on ($referenced)"; + $sql .= "FOREIGN KEY ($foreign) REFERENCES $on ($referenced)"; + + // Finally we will check for any "on delete" or "on update" options for + // the foreign key. These control the behavior of the constraint when + // an update or delete statement is run against the record. + if ( ! is_null($command->on_delete)) + { + $sql .= " ON DELETE {$command->on_delete}"; + } + + if ( ! is_null($command->on_update)) + { + $sql .= " ON UPDATE {$command->on_update}"; + } + + return $sql; } /** From 43212f8505421935938aa28d421b02b8ffe9f081 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 10:38:39 -0500 Subject: [PATCH 07/22] Fix bug in eloquent model. --- laravel/database/eloquent/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 93c92bba..ab3bd95c 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -404,7 +404,7 @@ abstract class Model { */ public function changed($attribute) { - array_get($this->attributes, $attribute) !== array_get($this->original, $attribute); + return array_get($this->attributes, $attribute) !== array_get($this->original, $attribute); } /** From 52ca2d35e70478dd8c24e0c0cc258a6de63ca8ed Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 10:48:49 -0500 Subject: [PATCH 08/22] Tweaking the Form::macro method. --- laravel/form.php | 63 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/laravel/form.php b/laravel/form.php index 32aff7e4..bd16787d 100644 --- a/laravel/form.php +++ b/laravel/form.php @@ -7,28 +7,25 @@ class Form { * * @var array */ - protected static $labels = array(); + public static $labels = array(); /** - * The registered custom inputs + * The registered custom macros. * * @var array */ - - protected static $inputs = array(); - - /** - * Dynamically handle calls to custom registered inputs. - */ + public static $macros = array(); - public static function __callStatic($method, $parameters) + /** + * Registers a custom macro. + * + * @param string $name + * @param Closure $input + * @return void + */ + public static function macro($name, $macro) { - if (isset(static::$inputs[$method])) - { - return call_user_func_array(static::$inputs[$method], $parameters); - } - - throw new \Exception("Method [$method] does not exist."); + static::$macros[$name] = $macro; } /** @@ -74,8 +71,7 @@ class Form { // Since PUT and DELETE methods are not actually supported by HTML forms, // we'll create a hidden input element that contains the request method - // and set the actual request method to POST. Laravel will look for the - // hidden element to determine the request method. + // and set the actual request method variable to POST. if ($method == 'PUT' or $method == 'DELETE') { $append = static::hidden(Request::spoofer, $method); @@ -83,19 +79,6 @@ class Form { return ''.$append.PHP_EOL; } - - /** - * Registers a custom input - * - * @param string $name - * @param Closure $input - * @return void - */ - - public static function register($name, $input) - { - static::$inputs[$name] = $input; - } /** * Determine the appropriate request method to use for a form. @@ -576,8 +559,7 @@ class Form { { // If an ID has been explicitly specified in the attributes, we will // use that ID. Otherwise, we will look for an ID in the array of - // label names as this makes it convenient to give input elements - // the same ID as their corresponding labels. + // label names so labels and their elements have the same ID. if (array_key_exists('id', $attributes)) { return $attributes['id']; @@ -589,4 +571,21 @@ class Form { } } + /** + * Dynamically handle calls to custom macros. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public static function __callStatic($method, $parameters) + { + if (isset(static::$inputs[$method])) + { + return call_user_func_array(static::$inputs[$method], $parameters); + } + + throw new \Exception("Method [$method] does not exist."); + } + } \ No newline at end of file From 41e066e2eec5e496b48abfa94c7d50e681c9d0a7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 10:49:09 -0500 Subject: [PATCH 09/22] Fix macros method. --- laravel/form.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/form.php b/laravel/form.php index bd16787d..63d2d9f5 100644 --- a/laravel/form.php +++ b/laravel/form.php @@ -580,9 +580,9 @@ class Form { */ public static function __callStatic($method, $parameters) { - if (isset(static::$inputs[$method])) + if (isset(static::$macros[$method])) { - return call_user_func_array(static::$inputs[$method], $parameters); + return call_user_func_array(static::$macros[$method], $parameters); } throw new \Exception("Method [$method] does not exist."); From 599c69b4335196d74282d8bbb10573814a3e86e9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 10:59:09 -0500 Subject: [PATCH 10/22] Updated .gitignore. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b017e3c3..e136a846 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -favicon.* \ No newline at end of file +favicon.* +.DS_Store \ No newline at end of file From 3c3e91368908717753f0bc71ac772c034b86fbc5 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:19:29 -0500 Subject: [PATCH 11/22] Renamed Route::load to Route::forward. --- laravel/routing/route.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/routing/route.php b/laravel/routing/route.php index f87b04d3..6349a0e8 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -380,7 +380,7 @@ class Route { { Filter::register($name, $callback); } - + /** * Calls the specified route and returns its response. * @@ -388,7 +388,7 @@ class Route { * @param string $uri * @return Response */ - public static function load($method, $uri) + public static function forward($method, $uri) { return Router::route(strtoupper($method), $uri)->call(); } From 0637042c01008680bed900ab2cbbf7392e6737ba Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:22:16 -0500 Subject: [PATCH 12/22] Added preserve option to File::rmdir. --- laravel/file.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/laravel/file.php b/laravel/file.php index b584d00d..749232e7 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -246,9 +246,10 @@ class File { * Recursively delete a directory. * * @param string $directory + * @param bool $preserve * @return void */ - public static function rmdir($directory) + public static function rmdir($directory, $preserve = false) { if ( ! is_dir($directory)) return; @@ -269,7 +270,7 @@ class File { } } - @rmdir($directory); + if ( ! $preserve) @rmdir($directory); } /** From b41bba45d70f240437b04c2305fff1b89c0b22c8 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:23:26 -0500 Subject: [PATCH 13/22] Added File::cleandir. --- laravel/file.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/laravel/file.php b/laravel/file.php index 749232e7..94147485 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -273,6 +273,17 @@ class File { if ( ! $preserve) @rmdir($directory); } + /** + * Empty the specified directory of all files and folders. + * + * @param string $directory + * @return void + */ + public static function cleandir($directory) + { + return static::rmdir($directory, true); + } + /** * Get the most recently modified file in a directory. * From 3c7a1270a71b8a9d3693d69057e7695fd3772c8f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:25:37 -0500 Subject: [PATCH 14/22] Added File::move and File::copy methods. --- laravel/file.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/laravel/file.php b/laravel/file.php index 94147485..ca08a9c5 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -68,6 +68,30 @@ class File { if (static::exists($path)) @unlink($path); } + /** + * Move a file to a new location. + * + * @param string $path + * @param string $target + * @return void + */ + public static function move($path, $target) + { + return rename($path, $target); + } + + /** + * Copy a file to a new location. + * + * @param string $path + * @param string $target + * @return void + */ + public static function copy($path, $target) + { + return copy($path, $target); + } + /** * Extract the file extension from a file path. * From 13a70bcc3aa02877f0178b89aa1d3e4283c1682a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:28:22 -0500 Subject: [PATCH 15/22] Added File::mkdir. --- laravel/file.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/laravel/file.php b/laravel/file.php index ca08a9c5..0346c83c 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -197,6 +197,18 @@ class File { return false; } + /** + * Create a new directory. + * + * @param string $path + * @param int $chmod + * @return void + */ + public static function mkdir($path, $chmod = 0777) + { + return ( ! is_dir($path)) ? mkdir($path, $chmod, true) : true; + } + /** * Move a directory from one location to another. * From 244d4bfd0781d47d85a1bdb664c239bfe427809c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:38:30 -0500 Subject: [PATCH 16/22] Fix bugs in Redis class. --- application/config/database.php | 6 +++- laravel/redis.php | 53 +++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/application/config/database.php b/application/config/database.php index e4852ba3..d5e6ac1b 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -113,7 +113,11 @@ return array( 'redis' => array( - 'default' => array('host' => '127.0.0.1', 'port' => 6379), + 'default' => array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 0 + ), ), diff --git a/laravel/redis.php b/laravel/redis.php index 446b7f15..d00b2f52 100644 --- a/laravel/redis.php +++ b/laravel/redis.php @@ -16,6 +16,13 @@ class Redis { */ protected $port; + /** + * The databse number the connection selects on load. + * + * @var int + */ + protected $database; + /** * The connection to the Redis database. * @@ -35,12 +42,14 @@ class Redis { * * @param string $host * @param string $port + * @param int $database * @return void */ - public function __construct($host, $port) + public function __construct($host, $port, $database = 0) { $this->host = $host; $this->port = $port; + $this->database = $database; } /** @@ -68,7 +77,9 @@ class Redis { throw new \Exception("Redis database [$name] is not defined."); } - static::$databases[$name] = new static($config['host'], $config['port']); + extract($config); + + static::$databases[$name] = new static($host, $port, $database); } return static::$databases[$name]; @@ -95,6 +106,17 @@ class Redis { $response = trim(fgets($this->connection, 512)); + return $this->parse($response); + } + + /** + * Parse and return the response from the Redis database. + * + * @param string $response + * @return mixed + */ + protected function parse($response) + { switch (substr($response, 0, 1)) { case '-': @@ -131,6 +153,8 @@ class Redis { throw new \Exception("Error making Redis connection: {$error} - {$message}"); } + $this->select($this->database); + return $this->connection; } @@ -191,18 +215,21 @@ class Redis { list($read, $response, $size) = array(0, '', substr($head, 1)); - do + if ($size > 0) { - // Calculate and read the appropriate bytes off of the Redis response. - // We'll read off the response in 1024 byte chunks until the entire - // response has been read from the database. - $block = (($remaining = $size - $read) < 1024) ? $remaining : 1024; + do + { + // Calculate and read the appropriate bytes off of the Redis response. + // We'll read off the response in 1024 byte chunks until the entire + // response has been read from the database. + $block = (($remaining = $size - $read) < 1024) ? $remaining : 1024; - $response .= fread($this->connection, $block); + $response .= fread($this->connection, $block); - $read += $block; + $read += $block; - } while ($read < $size); + } while ($read < $size); + } // The response ends with a trailing CRLF. So, we need to read that off // of the end of the file stream to get it out of the way of the next @@ -225,11 +252,11 @@ class Redis { $response = array(); // Iterate through each bulk response in the multi-bulk and parse it out - // using the "bulk" method since a multi-bulk response is just a list of - // plain old bulk responses. + // using the "parse" method since a multi-bulk response is just a list + // of plain old Redis database responses. for ($i = 0; $i < $count; $i++) { - $response[] = $this->bulk(trim(fgets($this->connection, 512))); + $response[] = $this->parse(trim(fgets($this->connection, 512))); } return $response; From e8fe1f172cc94da7af8c16859bdb3c609d707e16 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:41:31 -0500 Subject: [PATCH 17/22] Removed extra PHP_EOL from Form class. --- laravel/form.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/laravel/form.php b/laravel/form.php index 63d2d9f5..59cd2b18 100644 --- a/laravel/form.php +++ b/laravel/form.php @@ -77,7 +77,7 @@ class Form { $append = static::hidden(Request::spoofer, $method); } - return ''.$append.PHP_EOL; + return ''.$append; } /** @@ -190,7 +190,7 @@ class Form { $value = HTML::entities($value); - return ''.PHP_EOL; + return ''; } /** @@ -218,7 +218,7 @@ class Form { $attributes = array_merge($attributes, compact('type', 'name', 'value', 'id')); - return ''.PHP_EOL; + return ''; } /** @@ -367,7 +367,7 @@ class Form { if ( ! isset($attributes['cols'])) $attributes['cols'] = 50; - return ''.HTML::entities($value).''.PHP_EOL; + return ''.HTML::entities($value).''; } /** @@ -400,7 +400,7 @@ class Form { $html[] = static::option($value, $display, $selected); } - return ''.implode('', $html).''.PHP_EOL; + return ''.implode('', $html).''; } /** @@ -545,7 +545,7 @@ class Form { */ public static function button($value, $attributes = array()) { - return ''.HTML::entities($value).''.PHP_EOL; + return ''.HTML::entities($value).''; } /** From 033455cc51437f5e82fc2b1939109e87dbf63c68 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 11:48:14 -0500 Subject: [PATCH 18/22] Make migration table column lengths more realistic. --- laravel/cli/tasks/migrate/migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/cli/tasks/migrate/migrator.php b/laravel/cli/tasks/migrate/migrator.php index 0ee059ad..5bf7617b 100644 --- a/laravel/cli/tasks/migrate/migrator.php +++ b/laravel/cli/tasks/migrate/migrator.php @@ -154,9 +154,9 @@ class Migrator extends Task { // the bundle name and string migration name as an unique ID // for the migrations, allowing us to easily identify which // migrations have been run for each bundle. - $table->string('bundle'); + $table->string('bundle', 50); - $table->string('name'); + $table->string('name', 200); // When running a migration command, we will store a batch // ID with each of the rows on the table. This will allow From 91a6cb882e2500556c0a69a0991741f239f69b2c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 12:06:31 -0500 Subject: [PATCH 19/22] Added wrap_value function to grammar. --- laravel/database/grammar.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/laravel/database/grammar.php b/laravel/database/grammar.php index 9dcb34ee..055b97a9 100644 --- a/laravel/database/grammar.php +++ b/laravel/database/grammar.php @@ -91,19 +91,23 @@ abstract class Grammar { // the table and the column in keyword identifiers. foreach (explode('.', $value) as $segment) { - if ($segment == '*') - { - $wrapped[] = $segment; - } - else - { - $wrapped[] = sprintf($this->wrapper, $segment); - } + $wrapped[] = $this->wrap_value($segment); } return implode('.', $wrapped); } + /** + * Wrap a single string value in keyword identifiers. + * + * @param string $value + * @return string + */ + protected function wrap_value($value) + { + return ($value !== '*') ? sprintf($this->wrapper, $value) : $value; + } + /** * Create query parameters from an array of values. * From afb33c17751603c48941d505cd1727fc14cf0c6a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 13:10:59 -0500 Subject: [PATCH 20/22] Fix bug with table prefix and columns. --- laravel/database/grammar.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/laravel/database/grammar.php b/laravel/database/grammar.php index 055b97a9..13d92d8e 100644 --- a/laravel/database/grammar.php +++ b/laravel/database/grammar.php @@ -89,9 +89,18 @@ abstract class Grammar { // Since columns may be prefixed with their corresponding table // name so as to not make them ambiguous, we will need to wrap // the table and the column in keyword identifiers. - foreach (explode('.', $value) as $segment) + $segments = explode('.', $value); + + foreach ($segments as $key => $value) { - $wrapped[] = $this->wrap_value($segment); + if ($key == 0 and count($segments) > 1) + { + $wrapped[] = $this->wrap_table($value); + } + else + { + $wrapped[] = $this->wrap_value($value); + } } return implode('.', $wrapped); From 52091bda5fbc049758fd80a5b9c18ef13549629b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 13:40:52 -0500 Subject: [PATCH 21/22] Added "match" validation rule for regular expression checks. --- application/language/en/validation.php | 1 + laravel/validator.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/application/language/en/validation.php b/application/language/en/validation.php index 8c230f21..8285f1e9 100644 --- a/application/language/en/validation.php +++ b/application/language/en/validation.php @@ -36,6 +36,7 @@ return array( "in" => "The selected :attribute is invalid.", "integer" => "The :attribute must be an integer.", "ip" => "The :attribute must be a valid IP address.", + "match" => "The :attribute format is invalid.", "max" => array( "numeric" => "The :attribute must be less than :max.", "file" => "The :attribute must be less than :max kilobytes.", diff --git a/laravel/validator.php b/laravel/validator.php index 4d6d1683..77ac724a 100644 --- a/laravel/validator.php +++ b/laravel/validator.php @@ -611,6 +611,18 @@ class Validator { return preg_match('/^([-a-z0-9_-])+$/i', $value); } + /** + * Validate that an attribute passes a regular expression check. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validate_match($attribute, $value, $parameters) + { + return preg_match($parameters[0], $value); + } + /** * Validate the MIME type of a file upload attribute is in a set of MIME types. * From 2fe7cfd91049d6fb59eda1ca7a27cc956f53a50c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Mar 2012 13:41:57 -0500 Subject: [PATCH 22/22] Updated change log. --- changes.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/changes.txt b/changes.txt index cf990e5c..ba30f948 100644 --- a/changes.txt +++ b/changes.txt @@ -20,4 +20,8 @@ Changes for 3.1: - Added controller::detect method. - Added Cache::forever method. - Controller layouts now resolved in Laravel\Controller __construct. - - Rewrote Eloquent and included in core. \ No newline at end of file + - Rewrote Eloquent and included in core. + - Added "match" validation rule. + - Fixed table prefix bug. + - Added Form::macro method. + - Added Route::forward method. \ No newline at end of file