language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | laravel | framework | 86c225951ad64ce0d705f5def8b83cdee5f849a9.json | Dump autloads on migration creation again. | src/Illuminate/Database/Console/Migrations/MakeCommand.php | @@ -69,11 +69,24 @@ public function fire()
// Now we're ready to get the path where these migrations should be placed
// on disk. This may be specified via the package option on the command
// and we will verify that option to determine the appropriate paths.
+ $this->writeMigration($name, $table, $create);
+
+ $this->info('Migration created successfully!');
+ }
+
+ /**
+ * Write the migration file to disk.
+ *
+ * @param string $name
+ * @param string $table
+ * @param bool $create
+ * @return void
+ */
+ protected function writeMigration($name, $table, $create)
+ {
$path = $this->getMigrationPath();
$this->creator->create($name, $path, $table, $create);
-
- $this->info('Migration created successfully!');
}
/** | true |
Other | laravel | framework | 86c225951ad64ce0d705f5def8b83cdee5f849a9.json | Dump autloads on migration creation again. | src/Illuminate/Database/MigrationServiceProvider.php | @@ -35,6 +35,8 @@ public function register()
$this->registerMigrator();
$this->registerCommands();
+
+ $this->registerPostCreationHook();
}
/**
@@ -189,6 +191,27 @@ protected function registerMakeCommand()
});
}
+ /**
+ * Register the migration post create hook.
+ *
+ * @return void
+ */
+ protected function registerPostCreationHook()
+ {
+ $this->app->extend('migration.creator', function($creator, $app)
+ {
+ // After a new migration is created, we will tell the Composer manager to
+ // regenerate the auto-load files for the framework. This simply makes
+ // sure that a migration will get immediately available for loading.
+ $creator->afterCreate(function() use ($app)
+ {
+ $app['composer']->dumpAutoloads();
+ });
+
+ return $creator;
+ });
+ }
+
/**
* Get the services provided by the provider.
*
| true |
Other | laravel | framework | 86c225951ad64ce0d705f5def8b83cdee5f849a9.json | Dump autloads on migration creation again. | src/Illuminate/Foundation/Composer.php | @@ -35,17 +35,28 @@ public function __construct(Filesystem $files, $workingPath)
/**
* Regenerate the Composer autoloader files.
*
+ * @param string $extra
* @return void
*/
- public function dumpAutoloads()
+ public function dumpAutoloads($extra = '')
{
$process = $this->getProcess();
- $process->setCommandLine($this->findComposer().' dump-autoload --optimize');
+ $process->setCommandLine(trim($this->findComposer().' dump-autoload '.$extra));
$process->run();
}
+ /**
+ * Regenerate the optimized Composer autoloader files.
+ *
+ * @return void
+ */
+ public function dumpOptimized()
+ {
+ $this->dumpAutoloads('--optimize');
+ }
+
/**
* Get the composer command for the environment.
* | true |
Other | laravel | framework | 86c225951ad64ce0d705f5def8b83cdee5f849a9.json | Dump autloads on migration creation again. | tests/Foundation/FoundationComposerTest.php | @@ -16,7 +16,7 @@ public function testDumpAutoloadRunsTheCorrectCommand()
$files->shouldReceive('exists')->once()->with(__DIR__.'/composer.phar')->andReturn(true);
$process = m::mock('stdClass');
$composer->expects($this->once())->method('getProcess')->will($this->returnValue($process));
- $process->shouldReceive('setCommandLine')->once()->with('php composer.phar dump-autoload --optimize');
+ $process->shouldReceive('setCommandLine')->once()->with('php composer.phar dump-autoload');
$process->shouldReceive('run')->once();
$composer->dumpAutoloads();
@@ -29,7 +29,7 @@ public function testDumpAutoloadRunsTheCorrectCommandWhenComposerIsntPresent()
$files->shouldReceive('exists')->once()->with(__DIR__.'/composer.phar')->andReturn(false);
$process = m::mock('stdClass');
$composer->expects($this->once())->method('getProcess')->will($this->returnValue($process));
- $process->shouldReceive('setCommandLine')->once()->with('composer dump-autoload --optimize');
+ $process->shouldReceive('setCommandLine')->once()->with('composer dump-autoload');
$process->shouldReceive('run')->once();
$composer->dumpAutoloads(); | true |
Other | laravel | framework | 9c4f744ae1ad0794a41af3cbaeeeb36e0cbf27b7.json | Simplify configuration get. | src/Illuminate/Queue/Console/ListenCommand.php | @@ -74,7 +74,7 @@ protected function getQueue($connection)
{
if (is_null($connection))
{
- $connection = $this->laravel['config']->get("queue.default");
+ $connection = $this->laravel['config']['queue.default'];
}
$queue = $this->laravel['config']->get("queue.connections.{$connection}.queue", 'default');
| false |
Other | laravel | framework | 23f647c9ba5d5a4d5a16ad275b1be17f6a62eafa.json | Return SQS response from SqsClient
There are situations where you want to know response information after sending a message to SQS.
I'm not familiar with beanstalkd so didn't make the same change to the beanstalkd equivalent. | src/Illuminate/Queue/SqsQueue.php | @@ -44,7 +44,7 @@ public function push($job, $data = '', $queue = null)
{
$payload = $this->createPayload($job, $data);
- $this->sqs->sendMessage(array('QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload));
+ return $this->sqs->sendMessage(array('QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload));
}
/**
@@ -60,7 +60,7 @@ public function later($delay, $job, $data = '', $queue = null)
{
$payload = $this->createPayload($job, $data);
- $this->sqs->sendMessage(array(
+ return $this->sqs->sendMessage(array(
'QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload, 'DelaySeconds' => $delay,
@@ -106,4 +106,4 @@ public function getSqs()
return $this->sqs;
}
-}
\ No newline at end of file
+} | false |
Other | laravel | framework | 03c16cc6adba7065d50caa2308bc03512ad9a889.json | Fix response downloads. | src/Illuminate/Support/Facades/Response.php | @@ -1,6 +1,7 @@
<?php namespace Illuminate\Support\Facades;
use Illuminate\Support\Contracts\ArrayableInterface;
+use Symfony\Component\HttpFoundation\BinaryFileResponse;
class Response {
@@ -56,9 +57,16 @@ public static function stream($callback, $status = 200, array $headers = array()
* @param array $headers
* @return Symfony\Component\HttpFoundation\BinaryFileResponse
*/
- public static function download($file, $status = 200, $headers = array())
+ public static function download($file, $name = null, $headers = array())
{
- return new \Symfony\Component\HttpFoundation\BinaryFileResponse($file, $status, $headers);
+ $response = new BinaryFileResponse($file, 200, $headers, true, 'attachment');
+
+ if ( ! is_null($name))
+ {
+ return $response->setContentDisposition('attachment', $name);
+ }
+
+ return $response;
}
}
\ No newline at end of file | false |
Other | laravel | framework | 99d0fd9819b8a0a972a7b535d175e960ff50d14c.json | Allow default value in find method. | src/Illuminate/Database/Eloquent/Collection.php | @@ -15,16 +15,17 @@ class Collection extends BaseCollection {
* Find a model in the collection by key.
*
* @param mixed $key
+ * @param mixed $default
* @return Illuminate\Database\Eloquent\Model
*/
- public function find($key)
+ public function find($key, $default = null)
{
if (count($this->dictionary) == 0)
{
$this->buildDictionary();
}
- return $this->dictionary[$key];
+ return array_get($this->dictionary, $key, $default);
}
/** | true |
Other | laravel | framework | 99d0fd9819b8a0a972a7b535d175e960ff50d14c.json | Allow default value in find method. | tests/Database/DatabaseEloquentCollectionTest.php | @@ -41,6 +41,7 @@ public function testFindMethodFindsModelById()
$c = new Collection(array($mockModel));
$this->assertTrue($mockModel === $c->find(1));
+ $this->assertTrue('taylor' === $c->find(2, 'taylor'));
}
| true |
Other | laravel | framework | a54268697a6c544312dd0b610c68db5021d267d3.json | Remove duplicate variable | src/Illuminate/Database/Eloquent/Model.php | @@ -675,8 +675,6 @@ protected function performUpdate($query)
return false;
}
- $dirty = $this->getDirty();
-
// Once we have run the update operation, we will fire the "updated" event for
// this model instance. This will allow developers to hook into these after
// models are updated, giving them a chance to do any special processing. | false |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | src/Illuminate/Database/Migrations/Migrator.php | @@ -171,7 +171,7 @@ public function rollback($pretend = false)
// and properly reverse the entire database schema operation that ran.
foreach ($migrations as $migration)
{
- $this->runDown($migration, $pretend);
+ $this->runDown((object) $migration, $pretend);
}
return count($migrations); | true |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | src/Illuminate/Routing/Generators/stubs/destroy.php | @@ -1,7 +1,7 @@
/**
* Remove the specified resource from storage.
*
- * @param int $id
+ * @param int $id
* @return Response
*/
public function destroy($id) | true |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | src/Illuminate/Routing/Generators/stubs/edit.php | @@ -1,7 +1,7 @@
/**
* Show the form for editing the specified resource.
*
- * @param int $id
+ * @param int $id
* @return Response
*/
public function edit($id) | true |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | src/Illuminate/Routing/Generators/stubs/show.php | @@ -1,7 +1,7 @@
/**
* Display the specified resource.
*
- * @param int $id
+ * @param int $id
* @return Response
*/
public function show($id) | true |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | src/Illuminate/Routing/Generators/stubs/update.php | @@ -1,7 +1,7 @@
/**
* Update the specified resource in storage.
*
- * @param int $id
+ * @param int $id
* @return Response
*/
public function update($id) | true |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | tests/Routing/fixtures/controller.php | @@ -35,6 +35,7 @@ public function store()
/**
* Display the specified resource.
*
+ * @param int $id
* @return Response
*/
public function show($id)
@@ -45,6 +46,7 @@ public function show($id)
/**
* Show the form for editing the specified resource.
*
+ * @param int $id
* @return Response
*/
public function edit($id)
@@ -55,6 +57,7 @@ public function edit($id)
/**
* Update the specified resource in storage.
*
+ * @param int $id
* @return Response
*/
public function update($id)
@@ -65,6 +68,7 @@ public function update($id)
/**
* Remove the specified resource from storage.
*
+ * @param int $id
* @return Response
*/
public function destroy($id) | true |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | tests/Routing/fixtures/except_controller.php | @@ -25,6 +25,7 @@ public function store()
/**
* Show the form for editing the specified resource.
*
+ * @param int $id
* @return Response
*/
public function edit($id)
@@ -35,6 +36,7 @@ public function edit($id)
/**
* Update the specified resource in storage.
*
+ * @param int $id
* @return Response
*/
public function update($id)
@@ -45,6 +47,7 @@ public function update($id)
/**
* Remove the specified resource from storage.
*
+ * @param int $id
* @return Response
*/
public function destroy($id) | true |
Other | laravel | framework | 8f3126acb7a41781f8563e08def06eb4656798a7.json | Fix some tests. Cast migrations to objects. | tests/Routing/fixtures/only_controller.php | @@ -15,6 +15,7 @@ public function index()
/**
* Display the specified resource.
*
+ * @param int $id
* @return Response
*/
public function show($id) | true |
Other | laravel | framework | 7410a451984c43fb5b69420b031409d51660547b.json | Add some stuff to the phpunit file. | phpunit.xml | @@ -15,4 +15,13 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
+
+ <filter>
+ <whitelist addUncoveredFilesFromWhitelist="false">
+ <directory suffix=".php">src</directory>
+ <exclude>
+ <directory suffix=".php">vendor</directory>
+ </exclude>
+ </whitelist>
+ </filter>
</phpunit>
\ No newline at end of file | false |
Other | laravel | framework | b0b0fb6f762f360da2e89c0267bc9ee86fa65142.json | Fix bug in database connection. | src/Illuminate/Database/Connection.php | @@ -528,7 +528,7 @@ public function getName()
*/
public function getConfig($option)
{
- return array_get($config, $option);
+ return array_get($this->config, $option);
}
/** | false |
Other | laravel | framework | 5493147220256090fd510cb424fb870911c28638.json | Put array helper tests in correct function | tests/Support/SupportHelpersTest.php | @@ -45,14 +45,14 @@ public function testArrayPluck()
public function testArrayExcept()
{
$array = array('name' => 'taylor', 'age' => 26);
- $this->assertEquals(array('name' => 'taylor'), array_only($array, array('name')));
+ $this->assertEquals(array('age' => 26), array_except($array, array('name')));
}
public function testArrayOnly()
{
$array = array('name' => 'taylor', 'age' => 26);
- $this->assertEquals(array('age' => 26), array_except($array, array('name')));
+ $this->assertEquals(array('name' => 'taylor'), array_only($array, array('name')));
}
@@ -134,4 +134,4 @@ public function testValue()
$this->assertEquals('foo', value(function() { return 'foo'; }));
}
-}
\ No newline at end of file
+} | false |
Other | laravel | framework | ac5b414f988d5cd952a5749f87586ab9f1ac8d13.json | Use path and domain in session store. | src/Illuminate/Session/Store.php | @@ -461,12 +461,14 @@ public function hitsLottery()
*
* @param Illuminate\Cookie\CookieJar $cookie
* @param string $name
- * @param int $lifetime
+ * @param int $lifetime
+ * @param string $path
+ * @param string $domain
* @return void
*/
- public function getCookie(CookieJar $cookie, $name, $lifetime)
+ public function getCookie(CookieJar $cookie, $name, $lifetime, $path, $domain)
{
- return $cookie->make($name, $this->getSessionId(), $lifetime);
+ return $cookie->make($name, $this->getSessionId(), $lifetime, $path, $domain);
}
/** | false |
Other | laravel | framework | 1ca831d5f646e7985c5e4b8f2497a6f3b142fd5b.json | Change config option in file driver. | src/Illuminate/Session/SessionManager.php | @@ -21,7 +21,7 @@ protected function createCookieDriver()
*/
protected function createFileDriver()
{
- $path = $this->app['config']['session.path'];
+ $path = $this->app['config']['session.files'];
return new FileStore($this->app['files'], $path);
}
| false |
Other | laravel | framework | b816c0d5b8fd38d4b927d766daf2d4c5f265073b.json | Give description on error handlers that bomb out. | src/Illuminate/Exception/Handler.php | @@ -65,7 +65,9 @@ public function handle($exception, $fromConsole = false)
}
catch (\Exception $e)
{
- //
+ $location = $e->getMessage().' in '.$e->getFile().':'.$e->getLine();
+
+ $response = 'Error in exception handler: '.$location;
}
// If the handler returns a "non-null" response, we will return it so it | false |
Other | laravel | framework | 87a7b5687b4c5790c210c3617b2a81722bb810cc.json | Update documentation for mixed parameters
Signed-off-by: Dries Vints <dries.vints@gmail.com> | src/Illuminate/Routing/UrlGenerator.php | @@ -66,7 +66,7 @@ public function previous()
* Generate a absolute URL to the given path.
*
* @param string $path
- * @param array $parameters
+ * @param mixed $parameters
* @param bool $secure
* @return string
*/
@@ -154,7 +154,7 @@ protected function getScheme($secure)
* Get the URL to a named route.
*
* @param string $name
- * @param array $parameters
+ * @param mixed $parameters
* @param bool $absolute
* @return string
*/
@@ -211,7 +211,7 @@ protected function buildParameterList($route, array $params)
* Get the URL to a controller action.
*
* @param string $action
- * @param array $parameters
+ * @param mixed $parameters
* @param bool $absolute
* @return string
*/ | false |
Other | laravel | framework | aa0d5c24fb7e1a7199628244db38697f7c6e8a66.json | Remove array dependencies from url helpers
The $parameters variable is being type casted to an array in the to() function of UrlGenerator so there isn't a need to require the parameter to be an array.
Signed-off-by: Dries Vints <dries.vints@gmail.com> | src/Illuminate/Support/helpers.php | @@ -431,10 +431,10 @@ function secure_asset($path)
* Generate a HTTPS url for the application.
*
* @param string $path
- * @param array $parameters
+ * @param mixed $parameters
* @return string
*/
- function secure_url($path, array $parameters = array())
+ function secure_url($path, $parameters = array())
{
return url($path, $parameters, true);
}
@@ -619,11 +619,11 @@ function trans_choice($id, $number, array $parameters = array(), $domain = 'mess
* Generate a url for the application.
*
* @param string $path
- * @param array $parameters
+ * @param mixed $parameters
* @param bool $secure
* @return string
*/
- function url($path = null, array $parameters = array(), $secure = null)
+ function url($path = null, $parameters = array(), $secure = null)
{
$app = app();
| false |
Other | laravel | framework | 104396130b1795f1b7257a63740ef1db42c0d073.json | Refactor the creation of Eloquent models. | src/Illuminate/Database/Eloquent/Builder.php | @@ -175,9 +175,7 @@ public function getModels($columns = array('*'))
// also set the proper connection name for the model after we create it.
foreach ($results as $result)
{
- $models[] = $model = $this->model->newExisting();
-
- $model->setRawAttributes((array) $result, true);
+ $models[] = $model = $this->model->newFromBuilder($result);
$model->setConnection($connection);
} | true |
Other | laravel | framework | 104396130b1795f1b7257a63740ef1db42c0d073.json | Refactor the creation of Eloquent models. | src/Illuminate/Database/Eloquent/Model.php | @@ -262,9 +262,13 @@ public function newInstance($attributes = array(), $exists = false)
* @param array $attributes
* @return Illuminate\Database\Eloquent\Model
*/
- public function newExisting($attributes = array())
+ public function newFromBuilder($attributes = array())
{
- return $this->newInstance($attributes, true);
+ $instance = $this->newInstance(array(), true);
+
+ $instance->setRawAttributes((array) $attributes, true);
+
+ return $instance;
}
/** | true |
Other | laravel | framework | 104396130b1795f1b7257a63740ef1db42c0d073.json | Refactor the creation of Eloquent models. | tests/Database/DatabaseEloquentBuilderTest.php | @@ -131,12 +131,12 @@ public function testGetModelsProperlyHydratesModels()
$records[] = array('name' => 'taylor', 'age' => 26);
$records[] = array('name' => 'dayle', 'age' => 28);
$builder->getQuery()->shouldReceive('get')->once()->with(array('foo'))->andReturn($records);
- $model = m::mock('Illuminate\Database\Eloquent\Model');
+ $model = m::mock('Illuminate\Database\Eloquent\Model[getTable,getConnectionName,newInstance]');
$model->shouldReceive('getTable')->once()->andReturn('foobars');
$builder->getQuery()->shouldReceive('from')->once()->with('foobars');
$builder->setModel($model);
$model->shouldReceive('getConnectionName')->once()->andReturn('foo_connection');
- $model->shouldReceive('newExisting')->twice()->andReturn(new EloquentBuilderTestModelStub, new EloquentBuilderTestModelStub);
+ $model->shouldReceive('newInstance')->andReturnUsing(function() { return new EloquentBuilderTestModelStub; });
$models = $builder->getModels(array('foo'));
$this->assertEquals('taylor', $models[0]->name); | true |
Other | laravel | framework | eb8f512c44f8060a2f3043e6fcd6e7d1a5177c59.json | Fix bug in Eloquent model update routine. | src/Illuminate/Database/Eloquent/Model.php | @@ -659,22 +659,27 @@ public function save()
*/
protected function performUpdate($query)
{
- // If the updating event returns false, we will cancel the update operation so
- // developers can hook Validation systems into their models and cancel this
- // operation if the model does not pass validation. Otherwise, we update.
- if ($this->fireModelEvent('updating') === false)
+ $dirty = $this->getDirty();
+
+ if (count($dirty) > 0)
{
- return false;
- }
+ // If the updating event returns false, we will cancel the update operation so
+ // developers can hook Validation systems into their models and cancel this
+ // operation if the model does not pass validation. Otherwise, we update.
+ if ($this->fireModelEvent('updating') === false)
+ {
+ return false;
+ }
- $dirty = $this->getDirty();
+ $dirty = $this->getDirty();
- $this->setKeysForSaveQuery($query)->update($dirty);
+ // Once we have run the update operation, we will fire the "updated" event for
+ // this model instance. This will allow developers to hook into these after
+ // models are updated, giving them a chance to do any special processing.
+ $this->setKeysForSaveQuery($query)->update($dirty);
- // Once we have run the update operation, we will fire the "updated" event for
- // this model instance. This will allow developers to hook into these after
- // models are updated, giving them a chance to do any special processing.
- $this->fireModelEvent('updated', false);
+ $this->fireModelEvent('updated', false);
+ }
return true;
} | true |
Other | laravel | framework | eb8f512c44f8060a2f3043e6fcd6e7d1a5177c59.json | Fix bug in Eloquent model update routine. | src/Illuminate/Workbench/Starter.php | @@ -13,11 +13,11 @@ public static function start($path, $finder = null, $files = null)
{
$finder = $finder ?: new \Symfony\Component\Finder\Finder;
- $files = $files ?: new \Illuminate\Filesystem\Filesystem;
-
// We will use the finder to locate all "autoload.php" files in the workbench
// directory, then we will include them each so that they are able to load
// the appropriate classes and file used by the given workbench package.
+ $files = $files ?: new \Illuminate\Filesystem\Filesystem;
+
$autoloads = $finder->in($path)->files()->name('autoload.php');
foreach ($autoloads as $file)
@@ -26,4 +26,4 @@ public static function start($path, $finder = null, $files = null)
}
}
-}
+}
| true |
Other | laravel | framework | 8f80dd1aaa91834c02a963d6b352fc50efd31089.json | Fix bug in IronMQ connector. | src/Illuminate/Queue/Connectors/IronConnector.php | @@ -13,9 +13,9 @@ class IronConnector implements ConnectorInterface {
*/
public function connect(array $config)
{
- $config = array('token' => $config['token'], 'project_id' => $config['project']);
+ $ironConfig = array('token' => $config['token'], 'project_id' => $config['project']);
- return new IronQueue(new IronMQ($config), $config['queue']);
+ return new IronQueue(new IronMQ($ironConfig), $config['queue']);
}
}
\ No newline at end of file | false |
Other | laravel | framework | 1f58d8a3a6972eecb5bd88a4d713ee53c425cee9.json | Add support for releasing IronMQ messages. | src/Illuminate/Queue/Jobs/IronJob.php | @@ -88,7 +88,7 @@ public function delete()
*/
public function release($delay = 0)
{
- //
+ $this->iron->releaseMessage($this->queue, $this->job->id);
}
/** | false |
Other | laravel | framework | 68c49e5c17e8e9f6219736367f042d80d88f2c08.json | Fix Dispatcher Typos. | src/Illuminate/Database/Eloquent/Model.php | @@ -140,7 +140,7 @@ abstract class Model implements ArrayAccess, ArrayableInterface, JsonableInterfa
/**
* The event dispatcher instance.
*
- * @var Illuminate\Events\Dispacher
+ * @var Illuminate\Events\Dispatcher
*/
protected static $dispatcher;
@@ -1517,7 +1517,7 @@ public static function setConnectionResolver(Resolver $resolver)
*/
public static function getEventDispatcher()
{
- return static::$dispathcer;
+ return static::$dispatcher;
}
/** | false |
Other | laravel | framework | e4fa40a23f71d9b9643d29d6149727a7aa3cdca3.json | Fix bug in pivot class. | src/Illuminate/Database/Eloquent/Relations/Pivot.php | @@ -65,7 +65,7 @@ protected function setKeysForSaveQuery($query)
{
$query->where($this->foreignKey, $this->getAttribute($this->foreignKey));
- $query->where($this->otherKey, $this->getAttribute($this->otherKey));
+ return $query->where($this->otherKey, $this->getAttribute($this->otherKey));
}
/** | false |
Other | laravel | framework | f6f2a8c73973dc97b15b344967e4378e2905ec8a.json | Fix potential bug in fluent class. | src/Illuminate/Support/Fluent.php | @@ -61,7 +61,7 @@ public function getAttributes()
*/
public function __call($method, $parameters)
{
- $this->$method = count($parameters) > 0 ? $parameters[0] : true;
+ $this->attributes[$method] = count($parameters) > 0 ? $parameters[0] : true;
return $this;
} | false |
Other | laravel | framework | b3b561e095081aeac7b1b6e293e45f7764fb9ff0.json | Update the readme file. | readme.md | @@ -30,6 +30,7 @@
- Added `URL::previous` method for getting previous URL from `referer` $_SERVER variable.
- Renamed `path` helper to `url` for consistency.
- Added `App::shutdown` method for registering callbacks to be fired at very end of both web and Artisan life-cycle.
+- Added `saveMany` and `createMany` to 1:1, 1:*, and *:* relations.
## Beta 3
| false |
Other | laravel | framework | 6f49fc29697fa1a33320bfbc465e71a685a41190.json | Fix bug in fluent class. | src/Illuminate/Support/Fluent.php | @@ -21,7 +21,7 @@ public function __construct($attributes = array())
{
foreach ($attributes as $key => $value)
{
- $this->$key = $value;
+ $this->attributes[$key] = $value;
}
}
| false |
Other | laravel | framework | a597ed29dc35444f63c8b53273133b3838e3ea29.json | fix config option in listen command. | src/Illuminate/Queue/Console/ListenCommand.php | @@ -72,7 +72,7 @@ public function fire()
*/
protected function getQueue($connection)
{
- $queue = $this->laravel['config']->get("queue.{$connection}.queue", 'default');
+ $queue = $this->laravel['config']->get("queue.connections.{$connection}.queue", 'default');
return $this->input->getOption('queue') ?: $queue;
}
| false |
Other | laravel | framework | 3017062688b79b3a2205ea9a02c6dc3986a41d1b.json | fix bug in page detection. | src/Illuminate/Pagination/Environment.php | @@ -116,7 +116,14 @@ public function getPaginationView(Paginator $paginator)
*/
public function getCurrentPage()
{
- return $this->currentPage ?: $this->request->query->get('page', 1);
+ $page = (int) $this->currentPage ?: $this->request->query->get('page', 1);
+
+ if ($page < 1 or filter_var($page, FILTER_VALIDATE_INT) === false)
+ {
+ return 1;
+ }
+
+ return $page;
}
/** | true |
Other | laravel | framework | 3017062688b79b3a2205ea9a02c6dc3986a41d1b.json | fix bug in page detection. | tests/Pagination/PaginationEnvironmentTest.php | @@ -44,6 +44,12 @@ public function testCurrentPageCanBeRetrieved()
$env->setRequest($request);
$this->assertEquals(2, $env->getCurrentPage());
+
+ $env = $this->getEnvironment();
+ $request = Illuminate\Http\Request::create('http://foo.com?page=-1', 'GET');
+ $env->setRequest($request);
+
+ $this->assertEquals(1, $env->getCurrentPage());
}
| true |
Other | laravel | framework | 3017062688b79b3a2205ea9a02c6dc3986a41d1b.json | fix bug in page detection. | tests/Pagination/PaginationPaginatorTest.php | @@ -44,6 +44,17 @@ public function testPaginationContextHandlesPageLessThanOne()
}
+ public function testPaginationContextHandlesPageLessThanOneAsString()
+ {
+ $p = new Paginator($env = m::mock('Illuminate\Pagination\Environment'), array('foo', 'bar', 'baz'), 3, 2);
+ $env->shouldReceive('getCurrentPage')->once()->andReturn('-1');
+ $p->setupPaginationContext();
+
+ $this->assertEquals(2, $p->getLastPage());
+ $this->assertEquals(1, $p->getCurrentPage());
+ }
+
+
public function testPaginationContextHandlesPageInvalidFormat()
{
$p = new Paginator($env = m::mock('Illuminate\Pagination\Environment'), array('foo', 'bar', 'baz'), 3, 2); | true |
Other | laravel | framework | 5997f6c0b8bf728c32650986bb2402132f6603ca.json | Pass non-named routes through Form::open()
You can now pass non-named routes alongside urls to Form::open with the 'url' parameter. The UrlGenerator will validate if it's a valid url and will otherwise try to generate an url if it's a route.
Signed-off-by: Dries Vints <dries.vints@gmail.com> | src/Illuminate/Html/FormBuilder.php | @@ -530,7 +530,10 @@ protected function getAction(array $options)
// We will also check for a "route" or "action" parameter on the array so that
// developers can easily specify a route or controller action when creating
// a form providing a convenient interface for creating the form actions.
- if (isset($options['url'])) return $options['url'];
+ if (isset($options['url']))
+ {
+ return $this->getUrlAction($options['url']);
+ }
if (isset($options['route']))
{
@@ -548,6 +551,22 @@ protected function getAction(array $options)
return $this->url->current();
}
+ /**
+ * Get the action for a "url" option.
+ *
+ * @param array|string $options
+ * @return string
+ */
+ protected function getUrlAction($options)
+ {
+ if (is_array($options))
+ {
+ return $this->url->to($options[0], array_slice($options, 1));
+ }
+
+ return $this->url->to($options);
+ }
+
/**
* Get the action for a "route" option.
* | false |
Other | laravel | framework | 4289e6ccb3ace1beb240390bacb6f0dbca7b2cd7.json | add last method | src/Illuminate/Support/Collection.php | @@ -48,6 +48,16 @@ public function first()
return count($this->items) > 0 ? reset($this->items) : null;
}
+ /**
+ * Get the last item from the collection
+ *
+ * @return mixed|null
+ */
+ public function last()
+ {
+ return count($this->items) > 0 ? end($this->items) : null;
+ }
+
/**
* Execute a callback over each item.
*
| false |
Other | laravel | framework | 60f329b2ec008100971a7648c72b55ab0c978a88.json | replace camel_case with studly_case where needed | src/Illuminate/Database/Eloquent/Model.php | @@ -1246,7 +1246,7 @@ protected function getAttributeFromArray($key)
*/
public function hasGetMutator($key)
{
- return method_exists($this, 'get'.camel_case($key).'Attribute');
+ return method_exists($this, 'get'.studly_case($key).'Attribute');
}
/**
@@ -1258,7 +1258,7 @@ public function hasGetMutator($key)
*/
protected function mutateAttribute($key, $value)
{
- return $this->{'get'.camel_case($key).'Attribute'}($value);
+ return $this->{'get'.studly_case($key).'Attribute'}($value);
}
/**
@@ -1275,7 +1275,7 @@ public function setAttribute($key, $value)
// the model, such as "json_encoding" an listing of data for storage.
if ($this->hasSetMutator($key))
{
- $method = 'set'.camel_case($key).'Attribute';
+ $method = 'set'.studly_case($key).'Attribute';
return $this->{$method}($value);
}
@@ -1302,7 +1302,7 @@ public function setAttribute($key, $value)
*/
public function hasSetMutator($key)
{
- return method_exists($this, 'set'.camel_case($key).'Attribute');
+ return method_exists($this, 'set'.studly_case($key).'Attribute');
}
/**
@@ -1518,9 +1518,9 @@ public function getMutatedAttributes()
if (isset(static::$mutatorCache[$class]))
{
- return static::$mutatorCache[get_class($this)];
+ return static::$mutatorCache[get_class($this)];
}
-
+
return array();
}
| true |
Other | laravel | framework | 60f329b2ec008100971a7648c72b55ab0c978a88.json | replace camel_case with studly_case where needed | src/Illuminate/Database/Migrations/MigrationCreator.php | @@ -89,7 +89,7 @@ protected function getStub($table, $create)
*/
protected function populateStub($name, $stub, $table)
{
- $stub = str_replace('{{class}}', camel_case($name), $stub);
+ $stub = str_replace('{{class}}', studly_case($name), $stub);
// Here we will replace the table place-holders with the table specified by
// the developer, which is useful for quickly creating a tables creation | true |
Other | laravel | framework | 60f329b2ec008100971a7648c72b55ab0c978a88.json | replace camel_case with studly_case where needed | src/Illuminate/Database/Migrations/Migrator.php | @@ -285,7 +285,7 @@ public function resolve($file)
{
$file = implode('_', array_slice(explode('_', $file), 4));
- $class = camel_case($file);
+ $class = studly_case($file);
return new $class;
} | true |
Other | laravel | framework | 60f329b2ec008100971a7648c72b55ab0c978a88.json | replace camel_case with studly_case where needed | src/Illuminate/Validation/Validator.php | @@ -1298,7 +1298,7 @@ protected function parseRule($rule)
$rule = substr($rule, 0, $colon);
}
- return array(camel_case($rule), $parameters);
+ return array(studly_case($rule), $parameters);
}
/**
@@ -1334,7 +1334,7 @@ public function addImplicitExtensions(array $extensions)
foreach ($extensions as $rule => $extension)
{
- $this->implicitRules[] = camel_case($rule);
+ $this->implicitRules[] = studly_case($rule);
}
}
@@ -1361,7 +1361,7 @@ public function addImplicitExtension($rule, Closure $extension)
{
$this->addExtension($rule, $extension);
- $this->implicitRules[] = camel_case($rule);
+ $this->implicitRules[] = studly_case($rule);
}
/** | true |
Other | laravel | framework | 60f329b2ec008100971a7648c72b55ab0c978a88.json | replace camel_case with studly_case where needed | src/Illuminate/Workbench/Console/WorkbenchMakeCommand.php | @@ -95,9 +95,9 @@ protected function callComposerUpdate($path)
*/
protected function buildPackage()
{
- $vendor = camel_case($this->ask('What is vendor name of the package?'));
+ $vendor = studly_case($this->ask('What is vendor name of the package?'));
- $name = camel_case($this->ask('What is the package name?'));
+ $name = studly_case($this->ask('What is the package name?'));
$author = $this->ask('What is your name?');
| true |
Other | laravel | framework | 5e1fd17b4b1f64659799fa07076e1e4d7a67ea8d.json | fix bug in relationship hydration. | src/Illuminate/Database/Eloquent/Model.php | @@ -1146,7 +1146,13 @@ public function relationsToArray()
$key = snake_case($key);
}
- $attributes[$key] = $relation;
+ // If the relation value has been set, we will set it on this attributes
+ // list for returning. If it was not arrayable or null, we'll not set
+ // the value on the array because it is some type of invalid value.
+ if (isset($relation))
+ {
+ $attributes[$key] = $relation;
+ }
}
return $attributes; | false |
Other | laravel | framework | 16f9cf75b9d0e869bc1995741d4bddf91267fe21.json | move view error binding to a new booted event. | src/Illuminate/Foundation/Application.php | @@ -37,12 +37,19 @@ class Application extends Container implements HttpKernelInterface {
protected $booted = false;
/**
- * Get the booting callbacks.
+ * The array of booting callbacks.
*
* @var array
*/
protected $bootingCallbacks = array();
+ /**
+ * The array of booted callbacks.
+ *
+ * @var array
+ */
+ protected $bootedCallbacks = array();
+
/**
* All of the registered service providers.
*
@@ -448,9 +455,14 @@ public function boot()
$provider->boot();
}
- $this->fireBootingCallbacks();
+ $this->fireAppCallbacks($this->bootingCallbacks);
+ // Once the application has booted we will also fire some "booted" callbacks
+ // for any listeners that need to do work after this initial booting gets
+ // finished. This is useful when ordering the boot-up processes we run.
$this->booted = true;
+
+ $this->fireAppCallbacks($this->bootedCallbacks);
}
/**
@@ -464,14 +476,25 @@ public function booting($callback)
$this->bootingCallbacks[] = $callback;
}
+ /**
+ * Register a new "booted" listener.
+ *
+ * @param mixed $callback
+ * @return void
+ */
+ public function booted($callback)
+ {
+ $this->bootedCallbacks[] = $callback;
+ }
+
/**
* Call the booting callbacks for the application.
*
* @return void
*/
- protected function fireBootingCallbacks()
+ protected function fireAppCallbacks(array $callbacks)
{
- foreach ($this->bootingCallbacks as $callback)
+ foreach ($callbacks as $callback)
{
call_user_func($callback, $this);
} | true |
Other | laravel | framework | 16f9cf75b9d0e869bc1995741d4bddf91267fe21.json | move view error binding to a new booted event. | src/Illuminate/View/ViewServiceProvider.php | @@ -141,7 +141,7 @@ protected function registerSessionBinder()
{
list($app, $me) = array($this->app, $this);
- $app->before(function() use ($app, $me)
+ $app->booted(function() use ($app, $me)
{
// If the current session has an "errors" variable bound to it, we will share
// its value with all view instances so the views can easily access errors
@@ -180,4 +180,4 @@ public function sessionHasErrors($app)
}
-}
+}
| true |
Other | laravel | framework | 6bac1991a30edcc8782553ab860046306a259d46.json | Remove config references from ViewServiceProvider.
Signed-off-by: Ben Corlett <bencorlett@me.com> | src/Illuminate/View/ViewServiceProvider.php | @@ -84,9 +84,6 @@ public function registerBladeEngine($resolver)
// instance to pass into the engine so it can compile the views properly.
$compiler = new BladeCompiler($app['files'], $cache);
- $compiler->setContentTags($app['config']['view.content_tags']);
- $compiler->setRawContentTags($app['config']['view.raw_content_tags']);
-
return new CompilerEngine($compiler, $app['files']);
});
}
| false |
Other | laravel | framework | fda17884e186d1115eb30f957e28a85639899196.json | fix bug in query grammer. | src/Illuminate/Database/Query/Grammars/Grammar.php | @@ -188,6 +188,8 @@ protected function compileWheres(Builder $query)
{
$sql = array();
+ if (is_null($query->wheres)) return '';
+
// Each type of where clauses has its own compiler function which is responsible
// for actually creating the where clauses SQL. This helps keep the code nice
// and maintainable since each clause has a very small method that it uses. | false |
Other | laravel | framework | ca5b9bdcde45ea49dd85be465cc62cdd0daf18b1.json | remove preference for snake case from model. | src/Illuminate/Database/Eloquent/Model.php | @@ -365,9 +365,11 @@ public function belongsTo($related, $foreignKey = null)
* Define an polymorphic, inverse one-to-one or many relationship.
*
* @param string $name
+ * @param string $type
+ * @param string $id
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
- public function morphTo($name = null)
+ public function morphTo($name = null, $type = null, $id = null)
{
// If no name is provided, we will use the backtrace to get the function name
// since that is most likely the name of the polymorphic interface. We can
@@ -379,7 +381,14 @@ public function morphTo($name = null)
$name = snake_case($caller['function']);
}
- return $this->belongsTo($this->{"{$name}_type"}, "{$name}_id");
+ // Next we will guess the type and ID if necessary. The type and IDs may also
+ // be passed into the function so that the developers may manually specify
+ // them on the relations. Otherwise, we will just make a great estimate.
+ $type = $type ?: $name.'_type';
+
+ $id = $id ?: $id.'_id';
+
+ return $this->belongsTo($this->{$type}, $id);
}
/**
@@ -998,24 +1007,22 @@ public function relationsToArray()
*/
public function getAttribute($key)
{
- $snake = snake_case($key);
-
- $inAttributes = array_key_exists($snake, $this->attributes);
+ $inAttributes = array_key_exists($$key, $this->attributes);
// If the key references an attribute, we can just go ahead and return the
// plain attribute value from the model. This allows every attribute to
// be dynamically accessed through the _get method without accessors.
- if ($inAttributes or $this->hasGetMutator($snake))
+ if ($inAttributes or $this->hasGetMutator($$key))
{
- return $this->getPlainAttribute($snake);
+ return $this->getPlainAttribute($$key);
}
// If the key already exists in the relationships array, it just means the
// relationship has already been loaded, so we'll just return it out of
// here because there is no need to query within the relations twice.
- if (array_key_exists($snake, $this->relations))
+ if (array_key_exists($$key, $this->relations))
{
- return $this->relations[$snake];
+ return $this->relations[$$key];
}
// If the "attribute" exists as a method on the model, we will just assume
@@ -1025,7 +1032,7 @@ public function getAttribute($key)
{
$relations = $this->$key()->getResults();
- return $this->relations[$snake] = $relations;
+ return $this->relations[$$key] = $relations;
}
}
@@ -1094,8 +1101,6 @@ public function hasGetMutator($key)
*/
public function setAttribute($key, $value)
{
- $key = snake_case($key);
-
// First we will check for the presence of a mutator for the set operation
// which simply lets the developers tweak the attribute as it is set on
// the model, such as "json_encoding" an listing of data for storage. | false |
Other | laravel | framework | 28545f43611f619b7d5c79287177ee537f2416a0.json | remove script from framework. | composer.json | @@ -77,8 +77,5 @@
"dev-master": "4.0-dev"
}
},
- "scripts": {
- "post-autoload-dump": "./vendor/bin/classpreloader.php compile --config=preload/config.php --output=preload/compiled.php --fix_dir=1"
- },
"minimum-stability": "dev"
}
| false |
Other | laravel | framework | e1800bd62de541df76945c59ad3454009a170394.json | Fix optional parameter on Form::model() | src/Illuminate/Html/FormBuilder.php | @@ -121,7 +121,7 @@ public function open(array $options = array())
* @param array $options
* @return string
*/
- public function model($model, array $options)
+ public function model($model, array $options = array())
{
$this->model = $model;
| false |
Other | laravel | framework | 13b93d100e8eae06a633d07883c5f5f5220a7690.json | fix bug with eager loading. | src/Illuminate/Database/Eloquent/Relations/Relation.php | @@ -105,12 +105,17 @@ public function getAndResetWheres()
*/
public function removeFirstWhereClause()
{
- array_shift($this->getBaseQuery()->wheres);
+ $first = array_shift($this->getBaseQuery()->wheres);
+
+ $bindings = $this->getBaseQuery()->getBindings();
// When resetting the relation where clause, we want to shift the first element
// off of the bindings, leaving only the constraints that the developers put
// as "extra" on the relationships, and not original relation constraints.
- $bindings = array_slice($this->getBaseQuery()->getBindings(), 1);
+ if (array_key_exists('value', $first))
+ {
+ $bindings = array_slice($bindings, 1);
+ }
$this->getBaseQuery()->setBindings(array_values($bindings));
} | false |
Other | laravel | framework | e866588a64873177530ab463c2e31da80b8e091c.json | fix argument order. | src/Illuminate/Database/DatabaseManager.php | @@ -84,7 +84,7 @@ protected function makeConnection($name)
return call_user_func($this->extensions[$name], $config);
}
- return $this->factory->make($name, $config);
+ return $this->factory->make($config, $name);
}
/**
| false |
Other | laravel | framework | ee6716ec3e4fd7e1e4fe291731cfbd3e2f3cdbe2.json | pass name to db connection. | src/Illuminate/Database/Connection.php | @@ -84,25 +84,35 @@ class Connection implements ConnectionInterface {
*/
protected $tablePrefix = '';
+ /**
+ * The name of the database connection.
+ *
+ * @var string
+ */
+ protected $name;
+
/**
* Create a new database connection instance.
*
* @param PDO $pdo
* @param string $database
* @param string $tablePrefix
+ * @param string $name
* @return void
*/
- public function __construct(PDO $pdo, $database = '', $tablePrefix = '')
+ public function __construct(PDO $pdo, $database = '', $tablePrefix = '', $name = null)
{
+ $this->pdo = $pdo;
+
// First we will setup the default properties. We keep track of the DB
// name we are connected to since it is needed when some reflective
// type commands are run such as checking whether a table exists.
- $this->pdo = $pdo;
-
$this->database = $database;
$this->tablePrefix = $tablePrefix;
+ $this->name = $name;
+
// We need to initialize a query grammar and the query post processors
// which are both very important parts of the database abstractions
// so will initialize them to their default value to get started.
@@ -500,6 +510,16 @@ public function getPdo()
return $this->pdo;
}
+ /**
+ * Get the database connection name.
+ *
+ * @return string|null
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
/**
* Get the PDO driver name.
* | true |
Other | laravel | framework | ee6716ec3e4fd7e1e4fe291731cfbd3e2f3cdbe2.json | pass name to db connection. | src/Illuminate/Database/Connectors/ConnectionFactory.php | @@ -11,10 +11,11 @@ class ConnectionFactory {
/**
* Establish a PDO connection based on the configuration.
*
- * @param array $config
+ * @param array $config
+ * @param string $name
* @return Illuminate\Database\Connection
*/
- public function make(array $config)
+ public function make(array $config, $name = null)
{
if ( ! isset($config['prefix']))
{
@@ -23,7 +24,7 @@ public function make(array $config)
$pdo = $this->createConnector($config)->connect($config);
- return $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix']);
+ return $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $name);
}
/**
@@ -64,23 +65,24 @@ public function createConnector(array $config)
* @param PDO $connection
* @param string $database
* @param string $tablePrefix
+ * @param string $name
* @return Illuminate\Database\Connection
*/
- protected function createConnection($driver, PDO $connection, $database, $tablePrefix = '')
+ protected function createConnection($driver, PDO $connection, $database, $tablePrefix = '', $name = null)
{
switch ($driver)
{
case 'mysql':
- return new MySqlConnection($connection, $database, $tablePrefix);
+ return new MySqlConnection($connection, $database, $tablePrefix, $name);
case 'pgsql':
- return new PostgresConnection($connection, $database, $tablePrefix);
+ return new PostgresConnection($connection, $database, $tablePrefix, $name);
case 'sqlite':
- return new SQLiteConnection($connection, $database, $tablePrefix);
+ return new SQLiteConnection($connection, $database, $tablePrefix, $name);
case 'sqlsrv':
- return new SqlServerConnection($connection, $database, $tablePrefix);
+ return new SqlServerConnection($connection, $database, $tablePrefix, $name);
}
throw new \InvalidArgumentException("Unsupported driver [$driver]"); | true |
Other | laravel | framework | ee6716ec3e4fd7e1e4fe291731cfbd3e2f3cdbe2.json | pass name to db connection. | src/Illuminate/Database/DatabaseManager.php | @@ -84,7 +84,7 @@ protected function makeConnection($name)
return call_user_func($this->extensions[$name], $config);
}
- return $this->factory->make($config);
+ return $this->factory->make($name, $config);
}
/**
| true |
Other | laravel | framework | ee6716ec3e4fd7e1e4fe291731cfbd3e2f3cdbe2.json | pass name to db connection. | tests/Database/DatabaseConnectionFactoryTest.php | @@ -23,8 +23,8 @@ public function testMakeCallsCreateConnection()
$connector->shouldReceive('connect')->once()->with($config)->andReturn($pdo);
$factory->expects($this->once())->method('createConnector')->with($config)->will($this->returnValue($connector));
$mockConnection = m::mock('stdClass');
- $factory->expects($this->once())->method('createConnection')->with($this->equalTo('mysql'), $this->equalTo($pdo), $this->equalTo('database'), $this->equalTo('prefix'))->will($this->returnValue($mockConnection));
- $connection = $factory->make($config);
+ $factory->expects($this->once())->method('createConnection')->with($this->equalTo('mysql'), $this->equalTo($pdo), $this->equalTo('database'), $this->equalTo('prefix'), $this->equalTo('foo'))->will($this->returnValue($mockConnection));
+ $connection = $factory->make($config, 'foo');
$this->assertEquals($mockConnection, $connection);
} | true |
Other | laravel | framework | 9e9f32a4f371fdb8c18ddb21c7eabb51a8a63a78.json | implement array access on models. | src/Illuminate/Database/Eloquent/Model.php | @@ -2,6 +2,7 @@
use Closure;
use DateTime;
+use ArrayAccess;
use Illuminate\Events\Dispatcher;
use Illuminate\Database\Connection;
use Illuminate\Database\Eloquent\Relations\HasOne;
@@ -15,7 +16,7 @@
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
-abstract class Model implements ArrayableInterface, JsonableInterface {
+abstract class Model implements ArrayAccess, ArrayableInterface, JsonableInterface {
/**
* The connection name for the model.
@@ -1355,6 +1356,51 @@ public function __set($key, $value)
$this->setAttribute($key, $value);
}
+ /**
+ * Determine if the given attribute exists.
+ *
+ * @param mixed $offset
+ * @return bool
+ */
+ public function offsetExists($offset)
+ {
+ return isset($this->$offset);
+ }
+
+ /**
+ * Get the value for a given offset.
+ *
+ * @param mixed $offset
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ return $this->$offset;
+ }
+
+ /**
+ * Set the value for a given offset.
+ *
+ * @param mixed $offset
+ * @param mixed $value
+ * @return void
+ */
+ public function offsetSet($offset, $value)
+ {
+ $this->$offset = $value;
+ }
+
+ /**
+ * Unset the value for a given offset.
+ *
+ * @param mixed $offset
+ * @return void
+ */
+ public function offsetUnset($offset)
+ {
+ unset($this->$offset);
+ }
+
/**
* Determine if an attribute exists on the model.
* | false |
Other | laravel | framework | 105541d3540aba4485f651ff7cec27745c920b53.json | fix bug in form builder. | src/Illuminate/Html/FormBuilder.php | @@ -549,9 +549,11 @@ protected function getAction(array $options)
*/
protected function getAppendage($method)
{
+ $method = strtoupper($method);
+
if ($method == 'PUT' or $method == 'DELETE')
{
- $append = $this->hidden('_method', $method);
+ return $this->hidden('_method', $method);
}
return ''; | false |
Other | laravel | framework | 0124a458f4cd2306fef0f4989f781781d6e271bd.json | fix seed method on test case. | src/Illuminate/Foundation/Testing/TestCase.php | @@ -114,14 +114,12 @@ public function be(UserInterface $user, $driver = null)
/**
* Seed a given database connection.
*
- * @param string $connection
+ * @param string $class
* @return void
*/
- public function seed($connection = null)
+ public function seed($class = 'DatabaseSeeder')
{
- $connection = $this->app['db']->connection($connection);
-
- $this->app['seeder']->seed($connection, $this->app['path'].'/database/seeds');
+ $this->app[$class]->run();
}
/** | false |
Other | laravel | framework | 3b862b0693a4ce3e13ecd73c65a9fe81e8c752f9.json | Fix ternary expr and add a space between lines | src/Illuminate/Support/Str.php | @@ -182,7 +182,8 @@ public static function slug($title, $separator = '-')
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
// Convert all dashes/undescores into separator
- $flip = ($separator == '-' ? '_' : '-');
+ $flip = $separator == '-' ? '_' : '-';
+
$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
// Replace all separator characters and whitespace by a single separator | false |
Other | laravel | framework | f132e3e894ea5db842ef054759c03b0088f7c955.json | Extend Str::slug for better result consistency | src/Illuminate/Support/Str.php | @@ -181,6 +181,10 @@ public static function slug($title, $separator = '-')
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
+ // Convert all dashes/undescores into separator
+ $flip = ($separator == '-' ? '_' : '-');
+ $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
+
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
@@ -218,4 +222,4 @@ public static function startsWith($haystack, $needles)
return false;
}
-}
\ No newline at end of file
+} | false |
Other | laravel | framework | add7ee07f3b2f0304c1bec56f4365a8ae5d84d63.json | pass missing methods to console artisan. | src/Illuminate/Foundation/Artisan.php | @@ -70,4 +70,16 @@ protected function getArtisan()
return $this->artisan = ConsoleApplication::start($this->app);
}
+ /**
+ * Dynamically pass all missing methods to console Artisan.
+ *
+ * @param string $method
+ * @param array $parameters
+ * @return mixed
+ */
+ public function __call($method, $parameters)
+ {
+ return call_user_func_array(array($this->getArtisan(), $method), $parameters);
+ }
+
}
\ No newline at end of file | false |
Other | laravel | framework | 4035bbc94ae809005d5941514b744cfc482d92da.json | use check date in the date validator. | src/Illuminate/Validation/Validator.php | @@ -825,7 +825,11 @@ protected function validateRegex($attribute, $value, $parameters)
*/
protected function validateDate($attribute, $value)
{
- return strtotime($value) !== false;
+ if (strtotime($value) === false) return false;
+
+ $date = date_parse($value);
+
+ return checkdate($date['month'], $date['day'], $date['year']);
}
/** | false |
Other | laravel | framework | 37e2bd8bf1fae80641fac1da950bf7ed0f368ca0.json | make patchwork a dev dependency of support. | src/Illuminate/Support/composer.json | @@ -9,9 +9,9 @@
],
"require": {
"php": ">=5.3.0",
- "patchwork/utf8": "1.0.*"
},
"require-dev": {
+ "patchwork/utf8": "1.0.*",
"mockery/mockery": "0.7.2"
},
"autoload": { | false |
Other | laravel | framework | 3d13d49f322e4319e9f74fdeef2fdb33c2c364cc.json | fix bug in facade. | src/Illuminate/Support/Facades/Facade.php | @@ -24,7 +24,7 @@ abstract class Facade {
*/
public static function swap($instance)
{
- static::$resolvedInstance = $instance;
+ static::$resolvedInstance[static::getFacadeAccessor()] = $instance;
static::$app->instance(static::getFacadeAccessor(), $instance);
}
@@ -37,9 +37,11 @@ public static function swap($instance)
*/
public static function shouldReceive()
{
- static::$resolvedInstance = $mock = \Mockery::mock(get_class(static::getFacadeRoot()));
+ $name = static::getFacadeAccessor();
- static::$app->instance(static::getFacadeAccessor(), $mock);
+ static::$resolvedInstance[$name] = $mock = \Mockery::mock(get_class(static::getFacadeRoot()));
+
+ static::$app->instance($name, $mock);
return call_user_func_array(array($mock, 'shouldReceive'), func_get_args());
} | false |
Other | laravel | framework | d19064cc0882301b1c33676ec4c6bd4dbb758f61.json | use one more namespace | src/Illuminate/Foundation/Console/KeyGenerateCommand.php | @@ -1,5 +1,6 @@
<?php namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Str;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
@@ -62,7 +63,7 @@ public function fire()
*/
protected function getRandomKey()
{
- return Illuminate\Support\Str::random(32);
+ return Str::random(32);
}
} | false |
Other | laravel | framework | 33f6acba80dd743e173e52d1b0e1116c6700b4d3.json | add an environment method to app. | src/Illuminate/Foundation/Application.php | @@ -136,6 +136,16 @@ public function startExceptionHandling()
$provider->startHandling($this);
}
+ /**
+ * Get the current application environment.
+ *
+ * @return string
+ */
+ public function environment()
+ {
+ return $this['env'];
+ }
+
/**
* Detect the application's current environment.
*
@@ -146,9 +156,6 @@ public function detectEnvironment($environments)
{
$base = $this['request']->getHost();
- // First we will check to see if we have any command-line arguments and if
- // if we do we will set this environment based on those arguments as we
- // need to set it before each configurations are actually loaded out.
$arguments = $this['request']->server->get('argv');
if ($this->runningInConsole()) | false |
Other | laravel | framework | 9f162064acd421275de87f5a4dfe04915323c7d4.json | improve performance of snake case. | src/Illuminate/Support/Str.php | @@ -196,11 +196,9 @@ public static function slug($title, $separator = '-')
*/
public static function snake($value, $delimiter = '_')
{
- return trim(preg_replace_callback('/[A-Z]/', function($match) use ($delimiter)
- {
- return $delimiter.strtolower($match[0]);
+ $replace = '$1'.$delimiter.'$2';
- }, $value), $delimiter);
+ return ctype_lower($value) ? $value : strtolower(preg_replace('/(.)([A-Z])/', $replace, $value));
}
/** | false |
Other | laravel | framework | 33ef4462ff94c4f5916aca8b65a4d7ad4747f72d.json | Use path.public to set 'public' folder location | src/Illuminate/Foundation/Console/ServeCommand.php | @@ -32,9 +32,11 @@ public function fire()
$port = $this->input->getOption('port');
+ $public = $this->laravel['path.public'];
+
$this->info("Laravel development server started on {$host}:{$port}...");
- passthru("php -S {$host}:{$port} -t public server.php");
+ passthru("php -S {$host}:{$port} -t {$public} server.php");
}
/**
@@ -51,4 +53,4 @@ protected function getOptions()
);
}
-}
\ No newline at end of file
+} | false |
Other | laravel | framework | eb3b10aae62d00eeed18cb069ab8dcd51a8de6bc.json | update queue service provider. | src/Illuminate/Queue/QueueServiceProvider.php | @@ -3,6 +3,7 @@
use Illuminate\Support\ServiceProvider;
use Illuminate\Queue\Console\WorkCommand;
use Illuminate\Queue\Console\ListenCommand;
+use Illuminate\Queue\Connectors\SqsConnector;
use Illuminate\Queue\Connectors\SyncConnector;
use Illuminate\Queue\Connectors\BeanstalkdConnector;
@@ -123,7 +124,7 @@ protected function registerListenCommand()
*/
public function registerConnectors($manager)
{
- foreach (array('Sync', 'Beanstalkd') as $connector)
+ foreach (array('Sync', 'Beanstalkd', 'Sqs') as $connector)
{
$this->{"register{$connector}Connector"}($manager);
}
@@ -157,6 +158,20 @@ protected function registerBeanstalkdConnector($manager)
});
}
+ /**
+ * Register the Amazon SQS queue connector.
+ *
+ * @param Illuminate\Queue\QueueManager $manager
+ * @return void
+ */
+ protected function registerSqsConnector($manager)
+ {
+ $manager->addConnector('sqs', function()
+ {
+ return new SqsConnector;
+ });
+ }
+
/**
* Get the services provided by the provider.
*
| false |
Other | laravel | framework | ab4042741027289235d22980596a7c8eeb2c7852.json | convert arrays to message bags on redirect. | src/Illuminate/Http/RedirectResponse.php | @@ -1,5 +1,6 @@
<?php namespace Illuminate\Http;
+use Illuminate\Support\MessageBag;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Session\Store as SessionStore;
use Illuminate\Support\Contracts\MessageProviderInterface;
@@ -98,7 +99,7 @@ public function withErrors($provider)
}
else
{
- $this->with('errors', (array) $provider);
+ $this->with('errors', new MessageBag((array) $provider));
}
return $this; | true |
Other | laravel | framework | ab4042741027289235d22980596a7c8eeb2c7852.json | convert arrays to message bags on redirect. | tests/Http/HttpResponseTest.php | @@ -71,6 +71,16 @@ public function testFlashingErrorsOnRedirect()
$response->withErrors($provider);
}
+ public function testRedirectWithErrorsArrayConvertsToMessageBag()
+ {
+ $response = new RedirectResponse('foo.bar');
+ $response->setRequest(Request::create('/', 'GET', array('name' => 'Taylor', 'age' => 26)));
+ $response->setSession($session = m::mock('Illuminate\Session\Store'));
+ $session->shouldReceive('flash')->once()->with('errors', m::type('Illuminate\Support\MessageBag'));
+ $provider = array('foo' => 'bar');
+ $response->withErrors($provider);
+ }
+
}
class JsonableStub implements JsonableInterface { | true |
Other | laravel | framework | 3a4a1ef3ac563fa803fef73410cb7bf815cbac34.json | check relations on eloquent isset and unset. | composer.json | @@ -10,7 +10,7 @@
}
],
"require": {
- "php": ">=5.3.0",
+ "php": ">=5.3.7",
"ext-mcrypt": "*",
"ircmaxell/password-compat": "1.0.*",
"monolog/monolog": "1.3.*",
| true |
Other | laravel | framework | 3a4a1ef3ac563fa803fef73410cb7bf815cbac34.json | check relations on eloquent isset and unset. | src/Illuminate/Database/Eloquent/Model.php | @@ -1303,7 +1303,7 @@ public function __set($key, $value)
*/
public function __isset($key)
{
- return isset($this->attributes[$key]);
+ return isset($this->attributes[$key]) or isset($this->relations[$key]);
}
/**
@@ -1315,6 +1315,8 @@ public function __isset($key)
public function __unset($key)
{
unset($this->attributes[$key]);
+
+ unset($this->relations[$key]);
}
/** | true |
Other | laravel | framework | 58df6abe3793d5bb009601090ca3f4aa4ba09ce3.json | Require the Mcrypt extension | composer.json | @@ -11,6 +11,7 @@
],
"require": {
"php": ">=5.3.0",
+ "ext-mcrypt": "*",
"ircmaxell/password-compat": "1.0.*",
"monolog/monolog": "1.3.*",
"swiftmailer/swiftmailer": "4.3.*",
| false |
Other | laravel | framework | e121c1a6886113cd5a5ac8968160928cc02b972f.json | Remove unused variable. | src/Illuminate/View/ViewServiceProvider.php | @@ -110,9 +110,7 @@ public function registerViewFinder()
*/
public function registerEnvironment()
{
- $me = $this;
-
- $this->app['view'] = $this->app->share(function($app) use ($me)
+ $this->app['view'] = $this->app->share(function($app)
{
// Next we need to grab the engine resolver instance that will be used by the
// environment. The resolver will be used by an environment to get each of
@@ -182,4 +180,4 @@ public function sessionHasErrors($app)
}
-}
\ No newline at end of file
+} | false |
Other | laravel | framework | 46186ccbb8069514eac8b0dc5951f12afaa69dee.json | change method visibility. | src/Illuminate/Foundation/Application.php | @@ -272,7 +272,7 @@ public function register(ServiceProvider $provider, $options = array())
*
* @return void
*/
- protected function loadDeferredProviders()
+ public function loadDeferredProviders()
{
// We will simply spin through each of the deferred providers and register each
// one and boot them if the application has booted. This should make each of | false |
Other | laravel | framework | 67f70afe1f4cdb472ba6dc28b03090e5153fb167.json | update reasons and readme. | readme.md | @@ -1,5 +1,10 @@
# Laravel 4 Beta Change Log
+## Beta 3
+
+- Fixed a few things in the ArrayStore session driver.
+- Improve reasons in Password Broker.
+
## Beta 2
- Migrated to ircmaxell's [password-compat](http://github.com/ircmaxell/password_compat) library for PHP 5.5 forward compatibility on hashes. No backward compatibility breaks. | true |
Other | laravel | framework | 67f70afe1f4cdb472ba6dc28b03090e5153fb167.json | update reasons and readme. | src/Illuminate/Auth/Reminders/PasswordBroker.php | @@ -197,6 +197,8 @@ protected function validNewPasswords()
*/
protected function makeErrorRedirect($reason = '')
{
+ if ($reason != '') $reason = 'reminders.'.$reason;
+
return $this->redirect->refresh()->with('error', true)->with('reason', $reason);
}
| true |
Other | laravel | framework | 67f70afe1f4cdb472ba6dc28b03090e5153fb167.json | update reasons and readme. | tests/Auth/AuthPasswordBrokerTest.php | @@ -84,7 +84,7 @@ public function testRedirectIsReturnedByResetWhenUserCredentialsInvalid()
$mocks['users']->shouldReceive('retrieveByCredentials')->once()->with(array('creds'))->andReturn(null);
$mocks['redirect']->shouldReceive('refresh')->andReturn($redirect = m::mock('Illuminate\Http\RedirectResponse'));
$redirect->shouldReceive('with')->once()->with('error', true)->andReturn($redirect);
- $redirect->shouldReceive('with')->once()->with('reason', 'user')->andReturn($redirect);
+ $redirect->shouldReceive('with')->once()->with('reason', 'reminders.user')->andReturn($redirect);
$this->assertInstanceof('Illuminate\Http\RedirectResponse', $broker->reset(array('creds'), function() {}));
}
@@ -100,7 +100,7 @@ public function testRedirectReturnedByRemindWhenPasswordsDontMatch()
$request->shouldReceive('input')->once()->with('password_confirmation')->andReturn('bar');
$mocks['redirect']->shouldReceive('refresh')->andReturn($redirect = m::mock('Illuminate\Http\RedirectResponse'));
$redirect->shouldReceive('with')->once()->with('error', true)->andReturn($redirect);
- $redirect->shouldReceive('with')->once()->with('reason', 'password')->andReturn($redirect);
+ $redirect->shouldReceive('with')->once()->with('reason', 'reminders.password')->andReturn($redirect);
$this->assertInstanceof('Illuminate\Http\RedirectResponse', $broker->reset(array('creds'), function() {}));
}
@@ -116,7 +116,7 @@ public function testRedirectReturnedByRemindWhenPasswordNotSet()
$request->shouldReceive('input')->once()->with('password_confirmation')->andReturn(null);
$mocks['redirect']->shouldReceive('refresh')->andReturn($redirect = m::mock('Illuminate\Http\RedirectResponse'));
$redirect->shouldReceive('with')->once()->with('error', true)->andReturn($redirect);
- $redirect->shouldReceive('with')->once()->with('reason', 'password')->andReturn($redirect);
+ $redirect->shouldReceive('with')->once()->with('reason', 'reminders.password')->andReturn($redirect);
$this->assertInstanceof('Illuminate\Http\RedirectResponse', $broker->reset(array('creds'), function() {}));
}
@@ -132,7 +132,7 @@ public function testRedirectReturnedByRemindWhenPasswordsLessThanSixCharacters()
$request->shouldReceive('input')->once()->with('password_confirmation')->andReturn('abc');
$mocks['redirect']->shouldReceive('refresh')->andReturn($redirect = m::mock('Illuminate\Http\RedirectResponse'));
$redirect->shouldReceive('with')->once()->with('error', true)->andReturn($redirect);
- $redirect->shouldReceive('with')->once()->with('reason', 'password')->andReturn($redirect);
+ $redirect->shouldReceive('with')->once()->with('reason', 'reminders.password')->andReturn($redirect);
$this->assertInstanceof('Illuminate\Http\RedirectResponse', $broker->reset(array('creds'), function() {}));
}
@@ -149,7 +149,7 @@ public function testRedirectReturnedByRemindWhenRecordDoesntExistInTable()
$mocks['reminders']->shouldReceive('exists')->with($user, 'token')->andReturn(false);
$mocks['redirect']->shouldReceive('refresh')->andReturn($redirect = m::mock('Illuminate\Http\RedirectResponse'));
$redirect->shouldReceive('with')->once()->with('error', true)->andReturn($redirect);
- $redirect->shouldReceive('with')->once()->with('reason', 'token')->andReturn($redirect);
+ $redirect->shouldReceive('with')->once()->with('reason', 'reminders.token')->andReturn($redirect);
$this->assertInstanceof('Illuminate\Http\RedirectResponse', $broker->reset(array('creds'), function() {}));
} | true |
Other | laravel | framework | bcb60d1538df19c31825d19df2d5717e329ec8b0.json | allow plain text emails only. | src/Illuminate/Mail/Mailer.php | @@ -76,6 +76,19 @@ public function alwaysFrom($address, $name = null)
$this->from = compact('address', 'name');
}
+ /**
+ * Send a new message when only a plain part.
+ *
+ * @param string $view
+ * @param array $data
+ * @param mixed $callback
+ * @return void
+ */
+ public function plain($view, array $data, $callback)
+ {
+ return $this->send(array('text' => $view), $data, $callback);
+ }
+
/**
* Send a new message using a view.
*
@@ -86,7 +99,10 @@ public function alwaysFrom($address, $name = null)
*/
public function send($view, array $data, $callback)
{
- if (is_array($view)) list($view, $plain) = $view;
+ // First we need to parse the view, which could either be a string or an array
+ // containing both an HTML and plain text versions of the view which should
+ // be used when sending an e-mail. We will extract both of them out here.
+ list($view, $plain) = $this->parseView($view);
$data['message'] = $message = $this->createMessage();
@@ -95,16 +111,64 @@ public function send($view, array $data, $callback)
// Once we have retrieved the view content for the e-mail we will set the body
// of this message using the HTML type, which will provide a simple wrapper
// to creating view based emails that are able to receive arrays of data.
- $content = $this->getView($view, $data);
+ $this->addContent($message, $view, $plain, $data);
- $message->setBody($content, 'text/html');
+ $message = $message->getSwiftMessage();
+
+ return $this->sendSwiftMessage($message);
+ }
+
+ /**
+ * Add the content to a given message.
+ *
+ * @param Illuminate\Mail\Message $message
+ * @param string $view
+ * @param string $plain
+ * @param array $data
+ * @return void
+ */
+ protected function addContent($message, $view, $plain, $data)
+ {
+ if (isset($view))
+ {
+ $message->setBody($this->getView($view, $data), 'text/html');
+ }
if (isset($plain))
{
$message->addPart($this->getView($plain, $data), 'text/plain');
}
+ }
+
+ /**
+ * Parse the given view name or array.
+ *
+ * @param string|array $view
+ * @return array
+ */
+ protected function parseView($view)
+ {
+ if (is_string($view)) return array($view, null);
+
+ // If the given view is an array with numeric keys, we will just assume that
+ // both a "pretty" and "plain" view were provided, so we will return this
+ // array as is, since must should contain both views with numeric keys.
+ if (is_array($view) and isset($view[0]))
+ {
+ return $view;
+ }
- return $this->sendSwiftMessage($message->getSwiftMessage());
+ // If the view is an array, but doesn't contain numeric keys, we will assume
+ // the the views are being explicitly specified and will extract them via
+ // named keys instead, allowing the developers to use one or the other.
+ elseif (is_array($view))
+ {
+ return array(
+ array_get($view, 'html'), array_get($view, 'text')
+ );
+ }
+
+ throw new \InvalidArgumentException("Invalid view.");
}
/** | true |
Other | laravel | framework | bcb60d1538df19c31825d19df2d5717e329ec8b0.json | allow plain text emails only. | tests/Mail/MailMailerTest.php | @@ -50,6 +50,27 @@ public function testMailerSendSendsMessageWithProperPlainViewContent()
}
+ public function testMailerSendSendsMessageWithProperPlainViewContentWhenExplicit()
+ {
+ unset($_SERVER['__mailer.test']);
+ $mailer = $this->getMock('Illuminate\Mail\Mailer', array('createMessage'), $this->getMocks());
+ $message = m::mock('StdClass');
+ $mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message));
+ $view = m::mock('StdClass');
+ $mailer->getViewEnvironment()->shouldReceive('make')->once()->with('foo', array('data', 'message' => $message))->andReturn($view);
+ $mailer->getViewEnvironment()->shouldReceive('make')->once()->with('bar', array('data', 'message' => $message))->andReturn($view);
+ $view->shouldReceive('render')->twice()->andReturn('rendered.view');
+ $message->shouldReceive('setBody')->once()->with('rendered.view', 'text/html');
+ $message->shouldReceive('addPart')->once()->with('rendered.view', 'text/plain');
+ $message->shouldReceive('setFrom')->never();
+ $mailer->setSwiftMailer(m::mock('StdClass'));
+ $message->shouldReceive('getSwiftMessage')->once()->andReturn($message);
+ $mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message);
+ $mailer->send(array('html' => 'foo', 'text' => 'bar'), array('data'), function($m) { $_SERVER['__mailer.test'] = $m; });
+ unset($_SERVER['__mailer.test']);
+ }
+
+
public function testMessagesCanBeLoggedInsteadOfSent()
{
$mailer = $this->getMock('Illuminate\Mail\Mailer', array('createMessage'), $this->getMocks()); | true |
Other | laravel | framework | 651bf0125104bd655781f4889f95c1fda9fc2aa7.json | fix a couple of typos in readme. | readme.md | @@ -26,7 +26,7 @@
- Added `Config::hasGroup` method.
- Added `DB::unprepared` method for running raw, unprepared queries against PDO.
- Allow `:key` place-holder in MessageBag messages.
-- Added `Auth::validate` method for validating credentials without logging in.fatal
+- Added `Auth::validate` method for validating credentials without logging in.
- Added `Auth::stateless` method for logging in for a single request without sessions or cookies.
- Added `DB::extend` method for adding custom connection resolvers.
- Added `each` and `filter` methods to Eloquent collections.
@@ -51,4 +51,4 @@
- Added SQL and bindings array to database query exceptions.
- Allow manipulation of session using "dot" notation.
- Route regular expression constraints may now be defined globally via `Route::pattern`.
-- Auto-increment fields are now unsigned if the databsae system supports it.
\ No newline at end of file
+- Auto-increment fields are now unsigned if the database system supports it.
\ No newline at end of file | false |
Other | laravel | framework | 5db2ae9b7619c5d49955ff1b964678ac29e267f4.json | remove old import. | src/Illuminate/Routing/Controllers/Controller.php | @@ -4,7 +4,6 @@
use ReflectionClass;
use Illuminate\Routing\Router;
use Illuminate\Container\Container;
-use Doctrine\Common\Annotations\SimpleAnnotationReader;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Controller { | false |
Other | laravel | framework | 340810a187804801f078e054172750e7d998e7f4.json | pass primary to insertGetId. | src/Illuminate/Database/Eloquent/Model.php | @@ -495,7 +495,7 @@ public function save()
{
if ($this->incrementing)
{
- $this->$keyName = $query->insertGetId($this->attributes);
+ $this->$keyName = $query->insertGetId($this->attributes, $keyName);
}
else
{ | true |
Other | laravel | framework | 340810a187804801f078e054172750e7d998e7f4.json | pass primary to insertGetId. | tests/Database/DatabaseEloquentModelTest.php | @@ -174,7 +174,7 @@ public function testInsertProcess()
{
$model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps'));
$query = m::mock('Illuminate\Database\Eloquent\Builder');
- $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'))->andReturn(1);
+ $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1);
$model->expects($this->once())->method('newQuery')->will($this->returnValue($query));
$model->expects($this->once())->method('updateTimestamps');
| true |
Other | laravel | framework | a55b886f08668a0aee65752be6c4c9695746c9d6.json | use getSessionStore in request class. | src/Illuminate/Http/Request.php | @@ -283,7 +283,7 @@ public function flash($filter = null, $keys = array())
{
$flash = ( ! is_null($filter)) ? $this->$filter($keys) : $this->input();
- $this->sessionStore->flashInput($flash);
+ $this->getSessionStore()->flashInput($flash);
}
/**
@@ -315,7 +315,7 @@ public function flashExcept()
*/
public function flush()
{
- $this->sessionStore->flashInput(array());
+ $this->getSessionStore()->flashInput(array());
}
/** | false |
Other | laravel | framework | 8c47b5b8f108de1fccc70727d9c013c57dd1a4fa.json | fix bug in belongToMany when using first. | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -64,6 +64,19 @@ public function getResults()
return $this->get();
}
+ /**
+ * Execute the query and get the first result.
+ *
+ * @param array $columns
+ * @return mixed
+ */
+ public function first($columns = array('*'))
+ {
+ $results = $this->take(1)->get($columns);
+
+ return count($results) > 0 ? $results->first() : null;
+ }
+
/**
* Execute the query as a "select" statement.
* | false |
Other | laravel | framework | 751dff74fa541ec1a832320585abd8a9060e9f39.json | fix first method on eloquent builder. | src/Illuminate/Database/Eloquent/Builder.php | @@ -70,7 +70,7 @@ public function find($id, $columns = array('*'))
*/
public function first($columns = array('*'))
{
- return $this->get($columns)->first();
+ return $this->take(1)->get($columns)->first();
}
/** | true |
Other | laravel | framework | 751dff74fa541ec1a832320585abd8a9060e9f39.json | fix first method on eloquent builder. | tests/Database/DatabaseEloquentBuilderTest.php | @@ -29,9 +29,10 @@ public function testFindMethod()
public function testFirstMethod()
{
- $builder = $this->getMock('Illuminate\Database\Eloquent\Builder', array('get'), $this->getMocks());
+ $builder = $this->getMock('Illuminate\Database\Eloquent\Builder', array('get', 'take'), $this->getMocks());
$collection = m::mock('stdClass');
$collection->shouldReceive('first')->once()->andReturn('bar');
+ $builder->expects($this->once())->method('take')->with($this->equalTo(1))->will($this->returnValue($builder));
$builder->expects($this->once())->method('get')->with($this->equalTo(array('*')))->will($this->returnValue($collection));
$result = $builder->first(); | true |
Other | laravel | framework | 9fbabd3e897b3366b9a6c116e5d23768f648f5d0.json | fix doc block. | src/Illuminate/Encryption/Encrypter.php | @@ -140,7 +140,8 @@ protected function getJsonPayload($payload)
/**
* Create a MAC for the given value.
*
- * @parma
+ * @param string $value
+ * @return string
*/
protected function hash($value)
{ | false |
Other | laravel | framework | 28b6f2e6c9490d4d55ccdeeb6dbd8352c15bfb28.json | Add implicit extensions to validator | src/Illuminate/Validation/Factory.php | @@ -26,6 +26,13 @@ class Factory {
*/
protected $extensions = array();
+ /**
+ * All of the custom implicit validator extensions.
+ *
+ * @var array
+ */
+ protected $implicitExtensions = array();
+
/**
* The Validator resolver instance.
*
@@ -63,6 +70,8 @@ public function make(array $data, array $rules, array $messages = array())
$validator->addExtensions($this->extensions);
+ $validator->addImplicitExtensions($this->implicitExtensions);
+
return $validator;
}
@@ -98,6 +107,18 @@ public function extend($rule, Closure $extension)
$this->extensions[$rule] = $extension;
}
+ /**
+ * Register a custom implicit validator extension.
+ *
+ * @param string $rule
+ * @param Closure $extension
+ * @return void
+ */
+ public function extendImplicit($rule, Closure $extension)
+ {
+ $this->implicitExtensions[$rule] = $extension;
+ }
+
/**
* Set the Validator instance resolver.
* | true |
Other | laravel | framework | 28b6f2e6c9490d4d55ccdeeb6dbd8352c15bfb28.json | Add implicit extensions to validator | src/Illuminate/Validation/Validator.php | @@ -1318,6 +1318,22 @@ public function addExtensions(array $extensions)
$this->extensions = array_merge($this->extensions, $extensions);
}
+ /**
+ * Register an array of custom implicit validator extensions.
+ *
+ * @param array $extensions
+ * @return void
+ */
+ public function addImplicitExtensions(array $extensions)
+ {
+ $this->addExtensions($extensions);
+
+ foreach ($extensions as $rule => $extension)
+ {
+ $this->implicitRules[] = camel_case($rule);
+ }
+ }
+
/**
* Register a custom validator extension.
*
@@ -1330,6 +1346,20 @@ public function addExtension($rule, Closure $extension)
$this->extensions[$rule] = $extension;
}
+ /**
+ * Register a custom implicit validator extension.
+ *
+ * @param string $rule
+ * @param Closure $extension
+ * @return void
+ */
+ public function addImplicitExtension($rule, Closure $extension)
+ {
+ $this->addExtension($rule, $extension);
+
+ $this->implicitRules[] = camel_case($rule);
+ }
+
/**
* Get the data under validation.
* | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.