-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Class Illuminate\Database\Eloquent\Model use a missing dependency #55272
Comments
Hi, I can confirm this. |
use Illuminate\Http\Resources\TransformsToResource; Can all these traits be configurable via mixins? What if one chosses to not use resources from Laravel? We saw other people complaining about all these default traits in model. If they are a must they should not be traits but included in the model itself. That would solve also this issue. Laravel's habits are a rule (sadly). If the framework until now used to do something then that automatically validates that habit to be good. Guess what... |
What do you think of putting all these traits in a App/Models/Model.php file so each user can remove the traits he does not want to use? |
@macropay-solutions While you might (or might not) be right about the usefulness of certain traits, the functionality in question has its reasons why it belongs to the |
@shaedrich no one questions the logic here. You are right. The only thing is that the framework forces the user to use those traits even if they are not used in fact, while using the full framework or only Eloquent alone. For example, from all the traits the model uses: use Concerns\HasAttributes, In version 8 they were fewer: use Concerns\HasAttributes, Also a trait is useful when used multiple times to avoid duplicate code. The code from that TransformsToResource class can't be moved into the model without dependency to the http module in this case so a base model in laravel could solve these dependency issues. <?php
namespace App\Models;
use ...
abstract class Model extends EloquentModelAlias
{
use HasAttributes,
HasEvents,
HasGlobalScopes,
HasRelationships,
HasTimestamps,
HasUniqueIds,
HidesAttributes,
GuardsAttributes,
PreventsCircularRecursion,
ForwardsCalls;
/** @use HasCollection<\Illuminate\Database\Eloquent\Collection<array-key, static & self>> */
use HasCollection;
} And then the project's models will extend this App\Models\Model and will give the control to the developer to use or not some traits while also removing the dependency of database to http module. |
Except Laravel's not a modular framework (contrary to what the git tree split would leave you to believe) and you're really fighting against the grain if you're trying to use anything from this repository as a standalone component. Laravel wants you consuming the full stack framework, to the point that a decent chunk of the core tooling to build applications (like the entire I tried years ago to use parts of Laravel standalone and the longer I went with that project before life pushed me in other directions, the more it felt like I'd have been better off just building a Laravel application instead of just using Laravel's database tooling and the other resources I was using in that project. |
@mbabker @shaedrich @adriansuter @alepieser |
This was added in PR #55107, tagging the PR for ease of search |
Avoid regression issue introduced in #55107 fixes #55272 Signed-off-by: Mior Muhammad Zaki <[email protected]>
Avoid regression issue introduced in #55107 fixes #55272 Signed-off-by: Mior Muhammad Zaki <[email protected]>
@crynobone elegant solution. ;) but https://github.com/laravel/framework/pull/55309/files#r2030628748 Update. @crynobone Good job. |
Laravel Version
12.7.2
PHP Version
8.4
Database Driver & Version
No response
Description
Hello,
On different projects, we are using eloquent as standalone package.
Everything was working well since the release v12.6.0.
Since the version v12.7.x, the class Model is using a new trait coming from the package illuminate/http.
However this package is no part of the package required by database package.
Could you please add illuminate/http as required package into composer file ?
Steps To Reproduce
Just check the composer file & the line 20 of class Illuminate\Database\Eloquent\Model
The text was updated successfully, but these errors were encountered: