Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] add $default parameter to query builder when() method #15421

Closed
wants to merge 120 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
1f9a587
Added username, icon and channel options for Slack Notifications
Aug 20, 2016
32412ec
Renamed methods
Aug 20, 2016
5858edc
Fix jobs that cause indefinite looping if queue driver goes away (#15…
michaeldyrynda Sep 2, 2016
849b86b
fix multifile uploads when empty
themsaid Sep 2, 2016
6f6f9c8
simplify
themsaid Sep 2, 2016
782d14a
make it protected
themsaid Sep 3, 2016
5669d59
json_decodes Pusher message from validAuthentiactoinResponse [ Addres…
Sep 3, 2016
5d062ad
Add line below document block summary.
Sep 4, 2016
487e985
Corrected spelling of response.
Sep 5, 2016
eeae0bb
Adds X-RateLimit-Reset header to throttled response (#15275)
dschniepp Sep 5, 2016
6c3ecdc
Fix regression in save(touch) option (#15264)
Anahkiasen Sep 5, 2016
1ce9d8c
rename option for withCount
moritz-h Sep 5, 2016
24fca80
Merge branch 'fix-files' of https://github.com/themsaid/framework int…
taylorotwell Sep 5, 2016
37a3321
fix comment
taylorotwell Sep 5, 2016
9dfa42f
typo (#15249)
themsaid Sep 5, 2016
d45af77
Hide pagination if it does not have multiple pages. (#15246)
garygreen Sep 5, 2016
eeaf2eb
style fix
moritz-h Sep 5, 2016
903efd6
[5.3] Fix lower case model names in policy classes (#15270)
memu Sep 5, 2016
8b10200
Merge branch '5.3' of https://github.com/eahrold/framework into eahro…
taylorotwell Sep 5, 2016
e509b39
fix a bunch of things
taylorotwell Sep 5, 2016
d2c9665
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 5, 2016
95e19d2
use Str::lower
moritz-h Sep 5, 2016
dc46693
add issues template
themsaid Sep 5, 2016
fe71d3e
indicate the patch version is needed
themsaid Sep 5, 2016
02b95a8
Merge branch 'add-issue-template' of https://github.com/themsaid/fram…
taylorotwell Sep 5, 2016
3bd2712
tweak wording
taylorotwell Sep 5, 2016
1812e20
throw exception if failed to create queue payload (#15284)
themsaid Sep 5, 2016
95ac0eb
Allow models omitted by global scopes to be refreshed (#15282)
deefour Sep 5, 2016
b05f46a
Fix some phpdoc inconsistencies
lucasmichot Sep 6, 2016
4f6c6cb
Merge pull request #15297 from lucasmichot/feature/5.3/docblocks-cons…
GrahamCampbell Sep 6, 2016
4c0c08c
This closes #14832 by adding isReadable
themsaid Sep 5, 2016
cf7939c
[5.3] Refactor inTimeInterval method (#15306)
JacobBennett Sep 6, 2016
4bede79
Change url generating logic (#15291)
iwex Sep 6, 2016
d717488
Fix getDefaultDriver implementation (#15288)
anteriovieira Sep 6, 2016
6a766e9
Fire / check queue looping event before running daemon (#15290)
djtarazona Sep 6, 2016
0bea680
Fix #14743 by considering local key in the relation (#15303)
themsaid Sep 6, 2016
2bfef8b
[5.3] Add split method to collection class (#15302)
freekmurze Sep 6, 2016
018dea1
Merge branch 'isreadable' of https://github.com/themsaid/framework in…
taylorotwell Sep 6, 2016
0730ec5
fix method order
taylorotwell Sep 6, 2016
72f5a1d
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 6, 2016
e638b8c
Fail faster by checking Route Validators in likely fail order (#15287)
chrispittman Sep 6, 2016
822a1ae
Merge branch '5.3' of https://github.com/moritz-h/framework into mori…
taylorotwell Sep 6, 2016
dd29bbc
support aliases on withcount
taylorotwell Sep 6, 2016
3d44141
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 6, 2016
f971564
[5.3] Allow passing a Closure to View::share() method (#15312)
memu Sep 7, 2016
e68358d
close #15142 make the FilesystemAdapter::delete() behave like FileSys…
themsaid Sep 7, 2016
41eccb8
support for notifications MailChannel using messages that implements …
butschster Sep 7, 2016
f531e39
Fix StyleCI
butschster Sep 7, 2016
7b1916e
add unit test for Mailable Notification
butschster Sep 7, 2016
56c9d91
Fix StyleCI
butschster Sep 7, 2016
6cac4df
remove leading slash and extra brackets
butschster Sep 7, 2016
de2e30a
Check jobs before working to see if they have already been received t…
Sep 7, 2016
7520913
Style fixes for de2e30a80943702166f0e2cce9cf088a64a9e435
Sep 7, 2016
73752e0
Style fixes suggested in laravel/framework#15319
Sep 7, 2016
54d2c6b
Remove extra line
Sep 7, 2016
ae86295
[5.3] Added with* to Mailable (#15316)
jbrooksuk Sep 7, 2016
bd0ab83
fix formatting
taylorotwell Sep 7, 2016
212ffa1
add files
taylorotwell Sep 7, 2016
0e344e4
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 7, 2016
be927d3
Merge branch '5.3' of https://github.com/butschster/framework into bu…
taylorotwell Sep 7, 2016
a867036
slight formatting tweak
taylorotwell Sep 7, 2016
b8b57f1
Added path support for artisan migrate:rollback/refresh/reset fixes #…
anderly Sep 7, 2016
8fb8cea
fix comment
pakogn Sep 7, 2016
467c053
fix comment
pakogn Sep 7, 2016
9edb0ea
change comment
pakogn Sep 7, 2016
37b53c3
fix comment
pakogn Sep 7, 2016
acba391
Merge pull request #15324 from pakogn/patch-2
GrahamCampbell Sep 7, 2016
0652dbb
fix comments
pakogn Sep 7, 2016
7e70132
fix code styling
pakogn Sep 7, 2016
6600417
fix comment
pakogn Sep 7, 2016
99499d3
[5.3] Fix comments (#15325)
pakogn Sep 7, 2016
d1e3bde
fix comments
pakogn Sep 7, 2016
628bf65
Merge pull request #1 from pakogn/5.3
pakogn Sep 7, 2016
0aa7f34
fix comment
taylorotwell Sep 7, 2016
64a34f8
fix conflicts
taylorotwell Sep 7, 2016
13e84cb
[5.3] fix comments (#15326)
pakogn Sep 7, 2016
5deab59
add fakes for bus, events, mail, queue, notifications
taylorotwell Sep 8, 2016
18c3722
Merge branch 'fakes' into 5.3
taylorotwell Sep 8, 2016
d309c94
Applied fixes from StyleCI (#15328)
taylorotwell Sep 8, 2016
b4e6777
remove unnecessary code
taylorotwell Sep 8, 2016
f6128a3
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 8, 2016
32dcea9
Updated symfony/css-selector version. (#15344)
mahmutbayri Sep 8, 2016
a6f1cf5
Do not call useless floor() (#15343)
lucasmichot Sep 8, 2016
5394124
Fix inline docs for array_has (#15336)
ntzm Sep 8, 2016
bb7a505
close #12845 Allow numeric keys for morphMap (#15332)
themsaid Sep 8, 2016
91d25ee
fix #10501 by fixing morph to naming (#15334)
themsaid Sep 8, 2016
17e3367
Fix aggregate method sum() to always return number (#15345)
themsaid Sep 8, 2016
8b36861
increment version
taylorotwell Sep 8, 2016
4437643
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 8, 2016
86dd18d
Added release notes for v5.3.7 (#15346)
tillkruss Sep 8, 2016
62dd11d
Add later() method to MailableMailer as per docs
themsaid Sep 9, 2016
8d295af
Correct eloquent collection PHPDoc return types (#15362)
ntzm Sep 9, 2016
30bda12
Fix missing queue name on sync job
SanderSander Sep 9, 2016
ef5b4e1
shorten code
taylorotwell Sep 9, 2016
514df70
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 9, 2016
eb6e0fd
Fix fatal error on file uploads (#15350)
nhowell Sep 9, 2016
6524fea
formatting
taylorotwell Sep 9, 2016
eeebfcc
conflicts
taylorotwell Sep 9, 2016
3130be9
Add SSL options for Postgres DSN (#15371)
Belphemur Sep 9, 2016
d1d6e3a
Add ability to disable touching of parent when toggling relation (#15…
Anahkiasen Sep 9, 2016
634e748
[5.3] Minor support fixes (#15369)
ntzm Sep 9, 2016
b15e0de
Corrected Doc Block Response (#15373)
WayneHarris Sep 9, 2016
bb60a42
fix conflicts
taylorotwell Sep 9, 2016
a114bc6
Merge remote-tracking branch 'origin/5.3' into 5.3
taylorotwell Sep 9, 2016
69b08f6
rename method
taylorotwell Sep 9, 2016
99c74af
version
taylorotwell Sep 9, 2016
b5bfac0
Added release notes for v5.3.8 (#15379)
tillkruss Sep 9, 2016
43ebd2c
change to loosey comparison to allow queue to run without --tries
Sep 11, 2016
5c68fa0
fix cast
taylorotwell Sep 11, 2016
9007318
[5.3] Changed startsWith and endsWith to use substr (non mbstring) (#…
Perturbatio Sep 11, 2016
e831a9a
Applied fixes from StyleCI (#15395)
taylorotwell Sep 11, 2016
c7de016
[5.3] Restore support for non-string needle in Str::startsWith() (#15…
vlakoff Sep 12, 2016
f6fbb48
version
taylorotwell Sep 12, 2016
fca5200
Updates Service Provider class to use resource path over base path (#…
peterfox Sep 12, 2016
40438b3
Fix pcntl extension error for queue (#15393)
srmklive Sep 13, 2016
9219a30
add a $default parameter to the QB when() clause
tomschlick Sep 14, 2016
6dd3d44
add new test for when() method to test $default
tomschlick Sep 14, 2016
6f715ee
remove extra spaces to make StyleCI happy
tomschlick Sep 14, 2016
a8ea7a3
use the correct index for the bindings in the test
tomschlick Sep 14, 2016
6c0a740
use the full bindings array
tomschlick Sep 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion CHANGELOG-5.3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
# Release Notes for 5.3.x

## v5.3.8 (2016-09-09)

### Added
- Added missing `MailableMailer::later()` method ([#15364](https://github.com/laravel/framework/pull/15364))
- Added missing `$queue` parameter on `SyncJob` ([#15368](https://github.com/laravel/framework/pull/15368))
- Added SSL options for PostgreSQL DSN ([#15371](https://github.com/laravel/framework/pull/15371))
- Added ability to disable touching of parent when toggling relation ([#15263](https://github.com/laravel/framework/pull/15263))
- Added username, icon and channel options for Slack Notifications ([#14910](https://github.com/laravel/framework/pull/14910))

### Changed
- Updated `symfony/css-selector` version ([#15344](https://github.com/laravel/framework/pull/15344))
- Renamed methods in `NotificationFake` ([69b08f6](https://github.com/laravel/framework/commit/69b08f66fbe70b4df8332a8f2a7557a49fd8c693))
- Minor code improvements ([#15369](https://github.com/laravel/framework/pull/15369))

### Fixed
- Fixed catchable fatal error introduced [#15250](https://github.com/laravel/framework/pull/15250) ([#15350](https://github.com/laravel/framework/pull/15350))


## v5.3.7 (2016-09-08)

### Added
- Added missing translation for `mimetypes` validation ([#15209](https://github.com/laravel/framework/pull/15209), [#3921](https://github.com/laravel/laravel/pull/3921))
- Added ability to check if between two times when using scheduler ([#15216](https://github.com/laravel/framework/pull/15216), [#15306](https://github.com/laravel/framework/pull/15306))
- Added `X-RateLimit-Reset` header to throttled responses ([#15275](https://github.com/laravel/framework/pull/15275))
- Support aliases on `withCount()` ([#15279](https://github.com/laravel/framework/pull/15279))
- Added `Filesystem::isReadable()` ([#15289](https://github.com/laravel/framework/pull/15289))
- Added `Collection::split()` method ([#15302](https://github.com/laravel/framework/pull/15302))
- Allow passing a `Closure` to `View::share()` ([#15312](https://github.com/laravel/framework/pull/15312))
- Added support for `Mailable` messages in `MailChannel` ([#15318](https://github.com/laravel/framework/pull/15318))
- Added `with*()` syntax to `Mailable` class ([#15316](https://github.com/laravel/framework/pull/15316))
- Added `--path` option for `migrate:rollback/refresh/reset` ([#15251](https://github.com/laravel/framework/pull/15251))
- Allow numeric keys on `morphMap()` ([#15332](https://github.com/laravel/framework/pull/15332))
- Added fakes for bus, events, mail, queue and notifications ([5deab59](https://github.com/laravel/framework/commit/5deab59e89b85e09b2bd1642e4efe55e933805ca))

### Changed
- Update `Model::save()` to return `true` when no error occurs ([#15236](https://github.com/laravel/framework/pull/15236))
- Optimized performance of `Arr::first()` ([#15213](https://github.com/laravel/framework/pull/15213))
- Swapped `drop()` for `dropIfExists()` in all stubs ([#15230](https://github.com/laravel/framework/pull/15230))
- Allow passing object instance to `class_uses_recursive()` ([#15223](https://github.com/laravel/framework/pull/15223))
- Improved handling of failed file uploads during validation ([#15166](https://github.com/laravel/framework/pull/15166))
- Hide pagination if it does not have multiple pages ([#15246](https://github.com/laravel/framework/pull/15246))
- Cast Pusher message to JSON in `validAuthentiactoinResponse()` ([#15262](https://github.com/laravel/framework/pull/15262))
- Throw exception if queue failed to create payload ([#15284](https://github.com/laravel/framework/pull/15284))
- Call `getUrl()` first in `FilesystemAdapter::url()` ([#15291](https://github.com/laravel/framework/pull/15291))
- Consider local key in `HasManyThrough` relationships ([#15303](https://github.com/laravel/framework/pull/15303))
- Fail faster by checking Route Validators in likely fail order ([#15287](https://github.com/laravel/framework/pull/15287))
- Make the `FilesystemAdapter::delete()` behave like `FileSystem::delete()` ([#15308](https://github.com/laravel/framework/pull/15308))
- Don't call `floor()` in `Collection::median()` ([#15343](https://github.com/laravel/framework/pull/15343))
- Always return number from aggregate method `sum()` ([#15345](https://github.com/laravel/framework/pull/15345))

### Fixed
- Reverted "Hide empty paginators" [#15125](https://github.com/laravel/framework/pull/15125) ([#15241](https://github.com/laravel/framework/pull/15241))
- Fixed empty `multifile` uploads ([#15250](https://github.com/laravel/framework/pull/15250))
- Fixed regression in `save(touch)` option ([#15264](https://github.com/laravel/framework/pull/15264))
- Fixed lower case model names in policy classes ([15270](https://github.com/laravel/framework/pull/15270))
- Allow models with global scopes to be refreshed ([#15282](https://github.com/laravel/framework/pull/15282))
- Fix `ChannelManager::getDefaultDriver()` implementation ([#15288](https://github.com/laravel/framework/pull/15288))
- Fire `illuminate.queue.looping` event before running daemon ([#15290](https://github.com/laravel/framework/pull/15290))
- Check attempts before firing queue job ([#15319](https://github.com/laravel/framework/pull/15319))
- Fixed `morphTo()` naming inconsistency ([#15334](https://github.com/laravel/framework/pull/15334))


## v5.3.6 (2016-09-01)

### Added
Expand All @@ -19,7 +81,6 @@
- Optimized performance of `Str::random()` ([#15112](https://github.com/laravel/framework/pull/15112))
- Show `app.name` in auth stub ([#15138](https://github.com/laravel/framework/pull/15138))
- Switched from `htmlentities()` to `htmlspecialchars()` in `e()` helper ([#15159](https://github.com/laravel/framework/pull/15159))
- Improved handling of failed file uploads during validation ([#15166](https://github.com/laravel/framework/pull/15166))
- Hide empty paginators ([#15125](https://github.com/laravel/framework/pull/15125))

### Fixed
Expand Down
8 changes: 8 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- Laravel Version: #.#.#
- PHP Version:
- Database Driver & Version:

### Description:


### Steps To Reproduce:
20 changes: 17 additions & 3 deletions src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,28 @@ public function auth($request)
public function validAuthenticationResponse($request, $result)
{
if (Str::startsWith($request->channel_name, 'private')) {
return $this->pusher->socket_auth($request->channel_name, $request->socket_id);
return $this->decodePusherResponse(
$this->pusher->socket_auth($request->channel_name, $request->socket_id)
);
} else {
return $this->pusher->presence_auth(
$request->channel_name, $request->socket_id, $request->user()->id, $result
return $this->decodePusherResponse(
$this->pusher->presence_auth(
$request->channel_name, $request->socket_id, $request->user()->id, $result)
);
}
}

/**
* Decode the given Pusher response.
*
* @param mixed $response
* @return array
*/
protected function decodePusherResponse($response)
{
return json_decode($response, true);
}

/**
* Broadcast the given event.
*
Expand Down
8 changes: 2 additions & 6 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,10 @@ public function unlessBetween($startTime, $endTime)
*/
private function inTimeInterval($startTime, $endTime)
{
$startTime = str_replace(':', '', $startTime);

$endTime = str_replace(':', '', $endTime);

return function () use ($startTime, $endTime) {
$now = Carbon::now()->format('Hi');
$now = Carbon::now()->timestamp;

return $now >= $startTime && $now <= $endTime;
return $now >= strtotime($startTime) && $now <= strtotime($endTime);
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Contracts/Routing/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface UrlGenerator
public function current();

/**
* Generate a absolute URL to the given path.
* Generate an absolute URL to the given path.
*
* @param string $path
* @param mixed $extra
Expand All @@ -31,7 +31,7 @@ public function to($path, $extra = [], $secure = null);
public function secure($path, $parameters = []);

/**
* Generate a URL to an application asset.
* Generate the URL to an application asset.
*
* @param string $path
* @param bool $secure
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Connectors/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function setDefaultOptions(array $options)
}

/**
* Handle a exception that occurred during connect execution.
* Handle an exception that occurred during connect execution.
*
* @param \Exception $e
* @param string $dsn
Expand Down
12 changes: 12 additions & 0 deletions src/Illuminate/Database/Connectors/PostgresConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ protected function getDsn(array $config)
$dsn .= ";sslmode={$sslmode}";
}

if (isset($config['sslcert'])) {
$dsn .= ";sslcert={$sslcert}";
}

if (isset($config['sslkey'])) {
$dsn .= ";sslkey={$sslkey}";
}

if (isset($config['sslrootcert'])) {
$dsn .= ";sslrootcert={$sslrootcert}";
}

return $dsn;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Console/Migrations/RefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public function fire()

if ($step > 0) {
$this->call('migrate:rollback', [
'--database' => $database, '--force' => $force, '--step' => $step,
'--database' => $database, '--force' => $force, '--path' => $path, '--step' => $step,
]);
} else {
$this->call('migrate:reset', [
'--database' => $database, '--force' => $force,
'--database' => $database, '--force' => $force, '--path' => $path,
]);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Console/Migrations/ResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function fire()

// First, we'll make sure that the migration table actually exists before we
// start trying to rollback and re-run all of the migrations. If it's not
// present we will just bail out with a info message for the developer.
// present we'll just bail out with an info message for the developers.
if (! $this->migrator->repositoryExists()) {
return $this->comment('Migration table not found.');
}
Expand Down Expand Up @@ -88,6 +88,8 @@ protected function getOptions()

['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],

['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],

['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ protected function getOptions()

['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],

['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],

['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'],

['step', null, InputOption::VALUE_OPTIONAL, 'The number of migrations to be reverted.'],
Expand Down
20 changes: 17 additions & 3 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1056,11 +1056,20 @@ public function withCount($relations)
$relations = is_array($relations) ? $relations : func_get_args();

foreach ($this->parseWithRelations($relations) as $name => $constraints) {
// First we will determine if the name has been aliased using an "as" clause on the name
// and if it has we will extract the actual relationship name and the desired name of
// the resulting column. This allows multiple counts on the same relationship name.
$segments = explode(' ', $name);

if (count($segments) == 3 && Str::lower($segments[1]) == 'as') {
list($name, $alias) = [$segments[0], $segments[2]];
}

$relation = $this->getHasRelationQuery($name);

// Here we will get the relationship count query and prepare to add it to the main query
// as a sub-select. First, we'll get the "has" query and use that to get the relation
// count query. We will normalize the relation name then append _count as the name.
$relation = $this->getHasRelationQuery($name);

$query = $relation->getRelationCountQuery(
$relation->getRelated()->newQuery(), $this
);
Expand All @@ -1069,7 +1078,12 @@ public function withCount($relations)

$query->mergeModelDefinedRelationConstraints($relation->getQuery());

$this->selectSub($query->toBase(), snake_case($name).'_count');
// Finally we will add the proper result column alias to the query and run the subselect
// statement against the query builder. Then we will return the builder instance back
// to the developer for further constraint chaining that needs to take place on it.
$column = snake_case(isset($alias) ? $alias : $name).'_count';

$this->selectSub($query->toBase(), $column);
}

return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Eloquent/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function merge($items)
* Run a map over each of the items.
*
* @param callable $callback
* @return static
* @return \Illuminate\Support\Collection
*/
public function map(callable $callback)
{
Expand Down Expand Up @@ -176,7 +176,7 @@ public function intersect($items)
*
* @param string|callable|null $key
* @param bool $strict
* @return static
* @return static|\Illuminate\Support\Collection
*/
public function unique($key = null, $strict = false)
{
Expand Down
13 changes: 7 additions & 6 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ public function fresh($with = [])

$key = $this->getKeyName();

return static::with($with)->where($key, $this->getKey())->first();
return static::newQueryWithoutScopes()->with($with)->where($key, $this->getKey())->first();
}

/**
Expand Down Expand Up @@ -805,10 +805,10 @@ public function morphTo($name = null, $type = null, $id = null)
if (is_null($name)) {
list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);

$name = Str::snake($caller['function']);
$name = $caller['function'];
}

list($type, $id) = $this->getMorphs($name, $type, $id);
list($type, $id) = $this->getMorphs(Str::snake($name), $type, $id);

// If the type value is null it is probably safe to assume we're eager loading
// the relationship. In this case we'll just pass in a dummy query where we
Expand Down Expand Up @@ -1462,7 +1462,7 @@ public function save(array $options = [])
// clause to only update this model. Otherwise, we'll just insert them.
if ($this->exists) {
$saved = $this->isDirty() ?
$this->performUpdate($query) : true;
$this->performUpdate($query, $options) : true;
}

// If the model is brand new, we'll insert it into our database and set the
Expand Down Expand Up @@ -1515,9 +1515,10 @@ protected function finishSave(array $options)
* Perform a model update operation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $options
* @return bool
*/
protected function performUpdate(Builder $query)
protected function performUpdate(Builder $query, array $options = [])
{
// If the updating event returns false, we will cancel the update operation so
// developers can hook Validation systems into their models and cancel this
Expand All @@ -1529,7 +1530,7 @@ protected function performUpdate(Builder $query)
// First we need to create a fresh query instance and touch the creation and
// update timestamp on the model which are maintained by us for developer
// convenience. Then we will just continue saving the model instances.
if ($this->timestamps) {
if ($this->timestamps && Arr::get($options, 'touch', true)) {
$this->updateTimestamps();
}

Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ public function getOtherKey()
return $this->otherKey;
}

/**
* Get the name of the relationship.
*
* @return string
*/
public function getRelation()
{
return $this->relation;
}

/**
* Get the fully qualified associated key of the relationship.
*
Expand Down
5 changes: 3 additions & 2 deletions src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,10 @@ public function createMany(array $records, array $joinings = [])
* Each existing model is detached, and non existing ones are attached.
*
* @param mixed $ids
* @param bool $touch
* @return array
*/
public function toggle($ids)
public function toggle($ids, $touch = true)
{
$changes = [
'attached' => [], 'detached' => [],
Expand Down Expand Up @@ -849,7 +850,7 @@ public function toggle($ids)
$changes['attached'] = array_keys($attach);
}

if (count($changes['attached']) || count($changes['detached'])) {
if ($touch && (count($changes['attached']) || count($changes['detached']))) {
$this->touchIfTouching();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function addEagerConstraints(array $models)
{
$table = $this->parent->getTable();

$this->query->whereIn($table.'.'.$this->firstKey, $this->getKeys($models));
$this->query->whereIn($table.'.'.$this->firstKey, $this->getKeys($models, $this->localKey));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ public static function morphMap(array $map = null, $merge = true)
$map = static::buildMorphMapFromModels($map);

if (is_array($map)) {
static::$morphMap = $merge ? array_merge(static::$morphMap, $map) : $map;
static::$morphMap = $merge && static::$morphMap
? array_merge(static::$morphMap, $map) : $map;
}

return static::$morphMap;
Expand Down
Loading