Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

noni's avatar
Level 1

Where do I put non-Eloquent models in a Laravel project?

I want to add a model for TextComponent, which is only used within Laravel and doesn't have a database equivalent (so not extending Eloquent\Model). Where would I put such model files to keep them separate from all the Eloquent stuff?

I am using the default Laravel folder structure.

0 likes
6 replies
EveAT's avatar
EveAT
Best Answer
Level 26

Yes, you should separate non-Eloquent models for better organization. If TextComponent represents a domain concept consider placing it inside a subfolder within app/Models, such as app/Models/Domain or app/Models/ValueObjects (design pattern in DDD). If it is view-related, you can use app/ViewModels. If it's a utility, consider app/Support.

1 like
noni's avatar
Level 1

@EveAT Thank you! TextComponent is supposed to be a model that contains fields like text, font size, font family, coords, etc. I'm passing it to non-view-related methods such as FFmpegVideo->addText(TextComponent $t).

So I suppose app/Models/Domain is what I should be going with, correct?

1 like
AqeelUrRahman's avatar

Your Class TextComponent seems more like a helper class which you will be using in other classes. You should make use of Traits. It would give you better control and separation of logic.

noni's avatar
Level 1

@AqeelUrRahman My helper classes usually just contain a bunch of static utility methods. In this case I want to build a structured object that doesn't contain logic. I'm not sure how Traits would help with that. Could you elaborate?

AqeelUrRahman's avatar

You are right. If it contains only structure. You can have it in the separate folder which can be anywhere inside app folder, if you are going for domain driven development, then one domain will contain all the repository, controller, helper, services, request in it. e.g. app/UserDomain/User.php app/UserDomain/UserController.php app/UserDomain/UserService.php

1 like

Please or to participate in this conversation.