-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from caugner/firstOrCreate-firstOrNew
Ensure firstOrNew/Create can be called without parameters in Laravel 8+
- Loading branch information
Showing
8 changed files
with
256 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Illuminate\Database\Eloquent; | ||
/** | ||
* @template-covariant TModel of \Illuminate\Database\Eloquent\Model | ||
* @property-read HigherOrderBuilderProxy $orWhere | ||
* | ||
* @mixin \Illuminate\Database\Query\Builder | ||
*/ | ||
class Builder | ||
{ | ||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return TModel | ||
*/ | ||
public function firstOrNew(array $attributes, array $values = []) { } | ||
|
||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return TModel | ||
*/ | ||
public function firstOrCreate(array $attributes, array $values = []) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Illuminate\Database\Eloquent\Relations; | ||
|
||
/** | ||
* @template TRelatedModel of Model | ||
* @template-extends Relation<TRelatedModel> | ||
* @mixin \Illuminate\Database\Eloquent\Builder<TRelatedModel> | ||
*/ | ||
abstract class HasOneOrMany extends Relation | ||
{ | ||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return \Illuminate\Database\Eloquent\Model | ||
* @psalm-return TRelatedModel | ||
*/ | ||
public function firstOrNew(array $attributes, array $values = []) { } | ||
|
||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return \Illuminate\Database\Eloquent\Model | ||
* @psalm-return TRelatedModel | ||
*/ | ||
public function firstOrCreate(array $attributes, array $values = []) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Illuminate\Database\Eloquent; | ||
|
||
/** | ||
* @template-covariant TModel of \Illuminate\Database\Eloquent\Model | ||
* @property-read HigherOrderBuilderProxy $orWhere | ||
* | ||
* @mixin \Illuminate\Database\Query\Builder | ||
*/ | ||
class Builder | ||
{ | ||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return TModel | ||
*/ | ||
public function firstOrNew(array $attributes = [], array $values = []) { } | ||
|
||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return TModel | ||
*/ | ||
public function firstOrCreate(array $attributes = [], array $values = []) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Illuminate\Database\Eloquent\Relations; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
/** | ||
* @template TRelatedModel of Model | ||
* @template-extends Relation<TRelatedModel> | ||
* @mixin \Illuminate\Database\Eloquent\Builder<TRelatedModel> | ||
*/ | ||
abstract class HasOneOrMany extends Relation | ||
{ | ||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return \Illuminate\Database\Eloquent\Model | ||
* @psalm-return TRelatedModel | ||
*/ | ||
public function firstOrNew(array $attributes = [], array $values = []) { } | ||
|
||
/** | ||
* @param array $attributes | ||
* @param array $values | ||
* @return \Illuminate\Database\Eloquent\Model | ||
* @psalm-return TRelatedModel | ||
*/ | ||
public function firstOrCreate(array $attributes = [], array $values = []) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.