8000 [12.x] Fix `illuminate/database` usage as standalone package by crynobone · Pull Request #55309 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[12.x] Fix illuminate/database usage as standalone package #55309

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

Merged
merged 3 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Illuminate\Support\Traits;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use LogicException;

Expand All @@ -12,8 +11,8 @@ trait TransformsToResourceCollection
/**
* Create a new resource collection instance for the given resource.
*
* @param class-string<JsonResource>|null $resourceClass
* @return ResourceCollection
* @param class-string<\Illuminate\Http\Resources\Json\JsonResource>|null $resourceClass
* @return \Illuminate\Http\Resources\Json\ResourceCollection
*
* @throws \Throwable
*/
Expand All @@ -29,7 +28,7 @@ public function toResourceCollection(?string $resourceClass = null): ResourceCol
/**
* Guess the resource collection for the items.
*
* @return ResourceCollection
* @return \Illuminate\Http\Resources\Json\ResourceCollection
*
* @throws \Throwable
*/
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Collections/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
}
},
"suggest": {
"illuminate/http": "Required to convert collections to API resources (^12.0).",
"symfony/var-dumper": "Required to use the dump method (^7.2)."
},
"config": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Illuminate\Http\Resources;
namespace Illuminate\Database\Eloquent\Concerns;

use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Str;
Expand All @@ -11,8 +11,8 @@ trait TransformsToResource
/**
* Create a new resource object for the given resource.
*
* @param class-string<JsonResource>|null $resourceClass
* @return JsonResource
* @param class-string<\Illuminate\Http\Resources\Json\JsonResource>|null $resourceClass
* @return \Illuminate\Http\Resources\Json\JsonResource
*
* @throws \Throwable
*/
Expand All @@ -28,7 +28,7 @@ public function toResource(?string $resourceClass = null): JsonResource
/**
* Guess the resource class for the model.
*
* @return JsonResource
* @return \Illuminate\Http\Resources\Json\JsonResource
*
* @throws \Throwable
*/
Expand All @@ -46,7 +46,7 @@ protected function guessResource(): JsonResource
/**
* Guess the resource class name for the model.
*
* @return array<class-string<JsonResource>>
* @return array<class-string<\Illuminate\Http\Resources\Json\JsonResource>>
*/
public static function guessResourceName(): array
{
Expand Down
5 changes: 2 additions & 3 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Illuminate\Database\Eloquent\Relations\Concerns\AsPivot;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Http\Resources\TransformsToResource;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection as BaseCollection;
use Illuminate\Support\Str;
Expand All @@ -40,8 +39,8 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt
Concerns\HidesAttributes,
Concerns\GuardsAttributes,
Concerns\PreventsCircularRecursion,
ForwardsCalls,
TransformsToResource;
Concerns\TransformsToResource,
ForwardsCalls;
/** @use HasCollection<\Illuminate\Database\Eloquent\Collection<array-key, static & self>> */
use HasCollection;

Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Database/composer.json
644F
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"illuminate/console": "Required to use the database commands (^12.0).",
"illuminate/events": "Required to use the observers with Eloquent (^12.0).",
"illuminate/filesystem": "Required to use the migrations (^12.0).",
"illuminate/http": "Required to convert Eloquent models to API resources (^12.0).",
"illuminate/pagination": "Required to paginate the result set (^12.0).",
"symfony/finder": "Required to use Eloquent model factories (^7.2)."
},
Expand Down
Loading
0