mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
800e2347a6 | ||
|
|
7549f58a30 | ||
|
|
7740b80704 | ||
|
|
d6fb7907cc | ||
|
|
dc70337e48 | ||
|
|
4b051e45c7 | ||
|
|
07719015b3 | ||
|
|
7d2ea97f25 | ||
|
|
51fb97b8fb |
+12
-1
@@ -2,7 +2,16 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
[Next release](https://github.com/barryvdh/laravel-ide-helper/compare/v3.1.0...master)
|
[Next release](https://github.com/barryvdh/laravel-ide-helper/compare/v3.2.0...master)
|
||||||
|
--------------
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Add support for multiple pivot types when using the same accessor.
|
||||||
|
- Smarter reset, keep tags that IDE helper doesn't use
|
||||||
|
- Use `numeric` type on fields with `decimal` casts
|
||||||
|
|
||||||
|
|
||||||
|
2024-10-18, 3.2.0
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -14,6 +23,8 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Add support for AsCollection::using and AsEnumCollection::of casts [#1577 / uno-sw](https://github.com/barryvdh/laravel-ide-helper/pull/1577)
|
||||||
|
|
||||||
2024-07-12, 3.1.0
|
2024-07-12, 3.1.0
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class ModelsCommand extends Command
|
|||||||
],
|
],
|
||||||
['nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'],
|
['nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'],
|
||||||
['reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'],
|
['reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'],
|
||||||
['smart-reset', 'r', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'],
|
['smart-reset', 'r', InputOption::VALUE_NONE, 'Retained for compatibility, while it no longer has any effect'],
|
||||||
['phpstorm-noinspections', 'p', InputOption::VALUE_NONE,
|
['phpstorm-noinspections', 'p', InputOption::VALUE_NONE,
|
||||||
'Add PhpFullyQualifiedNameUsageInspection and PhpUnnecessaryFullyQualifiedNameInspection PHPStorm ' .
|
'Add PhpFullyQualifiedNameUsageInspection and PhpUnnecessaryFullyQualifiedNameInspection PHPStorm ' .
|
||||||
'noinspection tags',
|
'noinspection tags',
|
||||||
@@ -381,6 +381,8 @@ class ModelsCommand extends Command
|
|||||||
$realType = 'bool';
|
$realType = 'bool';
|
||||||
break;
|
break;
|
||||||
case 'decimal':
|
case 'decimal':
|
||||||
|
$realType = 'numeric';
|
||||||
|
break;
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'hashed':
|
case 'hashed':
|
||||||
$realType = 'string';
|
$realType = 'string';
|
||||||
@@ -410,8 +412,6 @@ class ModelsCommand extends Command
|
|||||||
case 'immutable_datetime':
|
case 'immutable_datetime':
|
||||||
$realType = '\Carbon\CarbonImmutable';
|
$realType = '\Carbon\CarbonImmutable';
|
||||||
break;
|
break;
|
||||||
case AsCollection::class:
|
|
||||||
case AsEnumCollection::class:
|
|
||||||
case 'collection':
|
case 'collection':
|
||||||
$realType = '\Illuminate\Support\Collection';
|
$realType = '\Illuminate\Support\Collection';
|
||||||
break;
|
break;
|
||||||
@@ -437,6 +437,18 @@ class ModelsCommand extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Str::startsWith($type, AsCollection::class)) {
|
||||||
|
$realType = $this->getTypeInModel($model, $params[0] ?? null) ?? '\Illuminate\Support\Collection';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Str::startsWith($type, AsEnumCollection::class)) {
|
||||||
|
$realType = '\Illuminate\Support\Collection';
|
||||||
|
$relatedModel = $this->getTypeInModel($model, $params[0] ?? null);
|
||||||
|
if ($relatedModel) {
|
||||||
|
$realType = $this->getCollectionTypeHint($realType, $relatedModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$realType = $this->checkForCastableCasts($realType, $params);
|
$realType = $this->checkForCastableCasts($realType, $params);
|
||||||
$realType = $this->checkForCustomLaravelCasts($realType);
|
$realType = $this->checkForCustomLaravelCasts($realType);
|
||||||
$realType = $this->getTypeOverride($realType);
|
$realType = $this->getTypeOverride($realType);
|
||||||
@@ -714,14 +726,25 @@ class ModelsCommand extends Command
|
|||||||
if ($relationObj instanceof BelongsToMany) {
|
if ($relationObj instanceof BelongsToMany) {
|
||||||
$pivot = get_class($relationObj->newPivot());
|
$pivot = get_class($relationObj->newPivot());
|
||||||
if (!in_array($pivot, [Pivot::class, MorphPivot::class])) {
|
if (!in_array($pivot, [Pivot::class, MorphPivot::class])) {
|
||||||
|
$pivot = $this->getClassNameInDestinationFile($model, $pivot);
|
||||||
|
|
||||||
|
if ($existingPivot = ($this->properties[$relationObj->getPivotAccessor()] ?? null)) {
|
||||||
|
// If the pivot is already set, we need to append the type to it
|
||||||
|
$pivot .= '|' . $existingPivot['type'];
|
||||||
|
} else {
|
||||||
|
// pivots are not always set
|
||||||
|
$pivot .= '|null';
|
||||||
|
}
|
||||||
|
|
||||||
$this->setProperty(
|
$this->setProperty(
|
||||||
$relationObj->getPivotAccessor(),
|
$relationObj->getPivotAccessor(),
|
||||||
$this->getClassNameInDestinationFile($model, $pivot),
|
$pivot,
|
||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Collection or array of models (because Collection is Arrayable)
|
//Collection or array of models (because Collection is Arrayable)
|
||||||
$relatedClass = '\\' . get_class($relationObj->getRelated());
|
$relatedClass = '\\' . get_class($relationObj->getRelated());
|
||||||
$collectionClass = $this->getCollectionClass($relatedClass);
|
$collectionClass = $this->getCollectionClass($relatedClass);
|
||||||
@@ -924,13 +947,19 @@ class ModelsCommand extends Command
|
|||||||
$reflection->getParentClass()->getInterfaceNames()
|
$reflection->getParentClass()->getInterfaceNames()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$phpdoc = new DocBlock($reflection, new Context($namespace));
|
||||||
if ($this->reset) {
|
if ($this->reset) {
|
||||||
$phpdoc = new DocBlock('', new Context($namespace));
|
|
||||||
$phpdoc->setText(
|
$phpdoc->setText(
|
||||||
(new DocBlock($reflection, new Context($namespace)))->getText()
|
(new DocBlock($reflection, new Context($namespace)))->getText()
|
||||||
);
|
);
|
||||||
} else {
|
foreach ($phpdoc->getTags() as $tag) {
|
||||||
$phpdoc = new DocBlock($reflection, new Context($namespace));
|
if (
|
||||||
|
in_array($tag->getName(), ['property', 'property-read', 'property-write', 'method', 'mixin'])
|
||||||
|
|| ($tag->getName() === 'noinspection' && in_array($tag->getContent(), ['PhpUnnecessaryFullyQualifiedNameInspection', 'PhpFullyQualifiedNameUsageInspection']))
|
||||||
|
) {
|
||||||
|
$phpdoc->deleteTag($tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$properties = [];
|
$properties = [];
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Collections;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class AdvancedCastCollection extends Collection
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Enums;
|
||||||
|
|
||||||
|
enum AdvancedCastEnum
|
||||||
|
{
|
||||||
|
case apple;
|
||||||
|
case banana;
|
||||||
|
case orange;
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models;
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Collections\AdvancedCastCollection;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Enums\AdvancedCastEnum;
|
||||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||||
use Illuminate\Database\Eloquent\Casts\AsCollection;
|
use Illuminate\Database\Eloquent\Casts\AsCollection;
|
||||||
use Illuminate\Database\Eloquent\Casts\AsEnumCollection;
|
use Illuminate\Database\Eloquent\Casts\AsEnumCollection;
|
||||||
@@ -11,21 +13,26 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class AdvancedCast extends Model
|
class AdvancedCast extends Model
|
||||||
{
|
{
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'cast_to_date_serialization' => 'date:Y-m-d',
|
{
|
||||||
'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s',
|
return [
|
||||||
'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s',
|
'cast_to_date_serialization' => 'date:Y-m-d',
|
||||||
'cast_to_immutable_date' => 'immutable_date',
|
'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s',
|
||||||
'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s',
|
'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s',
|
||||||
'cast_to_immutable_datetime' => 'immutable_datetime',
|
'cast_to_immutable_date' => 'immutable_date',
|
||||||
'cast_to_timestamp' => 'timestamp',
|
'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s',
|
||||||
'cast_to_encrypted' => 'encrypted',
|
'cast_to_immutable_datetime' => 'immutable_datetime',
|
||||||
'cast_to_encrypted_array' => 'encrypted:array',
|
'cast_to_timestamp' => 'timestamp',
|
||||||
'cast_to_encrypted_collection' => 'encrypted:collection',
|
'cast_to_encrypted' => 'encrypted',
|
||||||
'cast_to_encrypted_json' => 'encrypted:json',
|
'cast_to_encrypted_array' => 'encrypted:array',
|
||||||
'cast_to_encrypted_object' => 'encrypted:object',
|
'cast_to_encrypted_collection' => 'encrypted:collection',
|
||||||
'cast_to_as_collection' => AsCollection::class,
|
'cast_to_encrypted_json' => 'encrypted:json',
|
||||||
'cast_to_as_enum_collection' => AsEnumCollection::class,
|
'cast_to_encrypted_object' => 'encrypted:object',
|
||||||
'cast_to_as_array_object' => AsArrayObject::class,
|
'cast_to_as_collection' => AsCollection::class,
|
||||||
];
|
'cast_to_as_collection_using' => AsCollection::using(AdvancedCastCollection::class),
|
||||||
|
'cast_to_as_enum_collection' => AsEnumCollection::class,
|
||||||
|
'cast_to_as_enum_collection_of' => AsEnumCollection::of(AdvancedCastEnum::class),
|
||||||
|
'cast_to_as_array_object' => AsArrayObject::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models;
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Collections\AdvancedCastCollection;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Enums\AdvancedCastEnum;
|
||||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||||
use Illuminate\Database\Eloquent\Casts\AsCollection;
|
use Illuminate\Database\Eloquent\Casts\AsCollection;
|
||||||
use Illuminate\Database\Eloquent\Casts\AsEnumCollection;
|
use Illuminate\Database\Eloquent\Casts\AsEnumCollection;
|
||||||
@@ -27,6 +29,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* @property \Illuminate\Support\Collection $cast_to_as_collection
|
* @property \Illuminate\Support\Collection $cast_to_as_collection
|
||||||
* @property \Illuminate\Support\Collection $cast_to_as_enum_collection
|
* @property \Illuminate\Support\Collection $cast_to_as_enum_collection
|
||||||
* @property \ArrayObject $cast_to_as_array_object
|
* @property \ArrayObject $cast_to_as_array_object
|
||||||
|
* @property AdvancedCastCollection $cast_to_as_collection_using
|
||||||
|
* @property \Illuminate\Support\Collection<int, AdvancedCastEnum> $cast_to_as_enum_collection_of
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|AdvancedCast newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|AdvancedCast newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|AdvancedCast newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|AdvancedCast newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|AdvancedCast query()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|AdvancedCast query()
|
||||||
@@ -49,21 +53,26 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
*/
|
*/
|
||||||
class AdvancedCast extends Model
|
class AdvancedCast extends Model
|
||||||
{
|
{
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'cast_to_date_serialization' => 'date:Y-m-d',
|
{
|
||||||
'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s',
|
return [
|
||||||
'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s',
|
'cast_to_date_serialization' => 'date:Y-m-d',
|
||||||
'cast_to_immutable_date' => 'immutable_date',
|
'cast_to_datetime_serialization' => 'datetime:Y-m-d H:i:s',
|
||||||
'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s',
|
'cast_to_custom_datetime' => 'custom_datetime:Y-m-d H:i:s',
|
||||||
'cast_to_immutable_datetime' => 'immutable_datetime',
|
'cast_to_immutable_date' => 'immutable_date',
|
||||||
'cast_to_timestamp' => 'timestamp',
|
'cast_to_immutable_custom_datetime' => 'immutable_custom_datetime:Y-m-d H:i:s',
|
||||||
'cast_to_encrypted' => 'encrypted',
|
'cast_to_immutable_datetime' => 'immutable_datetime',
|
||||||
'cast_to_encrypted_array' => 'encrypted:array',
|
'cast_to_timestamp' => 'timestamp',
|
||||||
'cast_to_encrypted_collection' => 'encrypted:collection',
|
'cast_to_encrypted' => 'encrypted',
|
||||||
'cast_to_encrypted_json' => 'encrypted:json',
|
'cast_to_encrypted_array' => 'encrypted:array',
|
||||||
'cast_to_encrypted_object' => 'encrypted:object',
|
'cast_to_encrypted_collection' => 'encrypted:collection',
|
||||||
'cast_to_as_collection' => AsCollection::class,
|
'cast_to_encrypted_json' => 'encrypted:json',
|
||||||
'cast_to_as_enum_collection' => AsEnumCollection::class,
|
'cast_to_encrypted_object' => 'encrypted:object',
|
||||||
'cast_to_as_array_object' => AsArrayObject::class,
|
'cast_to_as_collection' => AsCollection::class,
|
||||||
];
|
'cast_to_as_collection_using' => AsCollection::using(AdvancedCastCollection::class),
|
||||||
|
'cast_to_as_enum_collection' => AsEnumCollection::class,
|
||||||
|
'cast_to_as_enum_collection_of' => AsEnumCollection::of(AdvancedCastEnum::class),
|
||||||
|
'cast_to_as_array_object' => AsArrayObject::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models;
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models;
|
||||||
|
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\CustomPivot;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\CustomPivot;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\DifferentCustomPivot;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class ModelWithPivot extends Model
|
class ModelWithPivot extends Model
|
||||||
@@ -15,4 +16,26 @@ class ModelWithPivot extends Model
|
|||||||
->using(CustomPivot::class)
|
->using(CustomPivot::class)
|
||||||
->as('customAccessor');
|
->as('customAccessor');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function relationWithDifferentCustomPivot()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(ModelwithPivot::class)
|
||||||
|
->using(DifferentCustomPivot::class)
|
||||||
|
->as('differentCustomAccessor');
|
||||||
|
}
|
||||||
|
|
||||||
|
// without an accessor
|
||||||
|
|
||||||
|
public function relationCustomPivotUsingSameAccessor()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(ModelwithPivot::class)
|
||||||
|
->using(CustomPivot::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationWithDifferentCustomPivotUsingSameAccessor()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(ModelwithPivot::class)
|
||||||
|
->using(DifferentCustomPivot::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
|
|
||||||
|
class DifferentCustomPivot extends Pivot
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -5,14 +5,23 @@ declare(strict_types=1);
|
|||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models;
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models;
|
||||||
|
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\CustomPivot;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\CustomPivot;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots\DifferentCustomPivot;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @property-read CustomPivot $customAccessor
|
* @property-read DifferentCustomPivot|CustomPivot|null $pivot
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationCustomPivotUsingSameAccessor
|
||||||
|
* @property-read int|null $relation_custom_pivot_using_same_accessor_count
|
||||||
|
* @property-read CustomPivot|null $customAccessor
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationWithCustomPivot
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationWithCustomPivot
|
||||||
* @property-read int|null $relation_with_custom_pivot_count
|
* @property-read int|null $relation_with_custom_pivot_count
|
||||||
|
* @property-read DifferentCustomPivot|null $differentCustomAccessor
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationWithDifferentCustomPivot
|
||||||
|
* @property-read int|null $relation_with_different_custom_pivot_count
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, ModelWithPivot> $relationWithDifferentCustomPivotUsingSameAccessor
|
||||||
|
* @property-read int|null $relation_with_different_custom_pivot_using_same_accessor_count
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|ModelWithPivot newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|ModelWithPivot newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|ModelWithPivot newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|ModelWithPivot newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|ModelWithPivot query()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|ModelWithPivot query()
|
||||||
@@ -26,6 +35,28 @@ class ModelWithPivot extends Model
|
|||||||
->using(CustomPivot::class)
|
->using(CustomPivot::class)
|
||||||
->as('customAccessor');
|
->as('customAccessor');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function relationWithDifferentCustomPivot()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(ModelwithPivot::class)
|
||||||
|
->using(DifferentCustomPivot::class)
|
||||||
|
->as('differentCustomAccessor');
|
||||||
|
}
|
||||||
|
|
||||||
|
// without an accessor
|
||||||
|
|
||||||
|
public function relationCustomPivotUsingSameAccessor()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(ModelwithPivot::class)
|
||||||
|
->using(CustomPivot::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function relationWithDifferentCustomPivotUsingSameAccessor()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(ModelwithPivot::class)
|
||||||
|
->using(DifferentCustomPivot::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
@@ -46,3 +77,22 @@ use Illuminate\Database\Eloquent\Relations\Pivot;
|
|||||||
class CustomPivot extends Pivot
|
class CustomPivot extends Pivot
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Pivot\Models\Pivots;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|DifferentCustomPivot newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|DifferentCustomPivot newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|DifferentCustomPivot query()
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class DifferentCustomPivot extends Pivot
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
/**
|
/**
|
||||||
* Text of existing phpdoc
|
* Text of existing phpdoc
|
||||||
*
|
*
|
||||||
|
* @implements \ArrayAccess
|
||||||
|
* @noinspection PhpUnreachableStatementInspection
|
||||||
|
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
||||||
* @property string $foo
|
* @property string $foo
|
||||||
|
* @property-read string $bar
|
||||||
|
* @method fooBar()
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Simple extends Model
|
class Simple extends Model
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
/**
|
/**
|
||||||
* Text of existing phpdoc
|
* Text of existing phpdoc
|
||||||
*
|
*
|
||||||
|
* @implements \ArrayAccess
|
||||||
|
* @noinspection PhpUnreachableStatementInspection
|
||||||
|
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
|
||||||
* @property string $foo
|
* @property string $foo
|
||||||
|
* @property-read string $bar
|
||||||
|
* @method fooBar()
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
/**
|
/**
|
||||||
* Text of existing phpdoc
|
* Text of existing phpdoc
|
||||||
*
|
*
|
||||||
|
* @implements \ArrayAccess
|
||||||
|
* @noinspection PhpUnreachableStatementInspection
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* @property float $cast_to_real
|
* @property float $cast_to_real
|
||||||
* @property float $cast_to_float
|
* @property float $cast_to_float
|
||||||
* @property float $cast_to_double
|
* @property float $cast_to_double
|
||||||
* @property string $cast_to_decimal
|
* @property numeric $cast_to_decimal
|
||||||
* @property string $cast_to_string
|
* @property string $cast_to_string
|
||||||
* @property bool $cast_to_bool
|
* @property bool $cast_to_bool
|
||||||
* @property bool $cast_to_boolean
|
* @property bool $cast_to_boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user