Search code examples
laravelmodel

How to work with non-ORM models in laravel?


A model is an object that has only state and no behavior, used in business logic.

Eloquent-ORM models fall under this definition. And under the same definition falls the PlotOptions class, which provides values for drop-down menus and has nothing to do with the database.

class PlotOptions {

    public array $water = ["...", "...", "..."];
    public array $gas = ["...", "..."];
    public array $electricity = ["...", "...", "...", "..."];
    public array $sewer = ["...", "...", "..."];
}

However, the Models directory is already reserved for ORM models.

How should such classes as PlotOptions be categorized and in which directory should they be stored?


Solution

  • I believe you can just create a folder in the app directory and put a namespace like

    namespace App\ExampleFolder;
    

    then you can access the class by using

    use App\ExampleFolder\PlotOptions;