- How do I install escolalms/model-fields in a Laravel application?
- Install it with Composer as escolalms/model-fields and let Laravel's package discovery register the service provider. Then publish any configuration or migration files the package ships with and run your migrations, because field definitions are stored as data rather than in your models. Check the repository README for the exact publish tags and setup steps.
- Does escolalms/model-fields require new migrations for each custom field?
- No. The point of the package is that you define field schemas as data instead of writing a new migration for every attribute, so the tables of the models you extend stay untouched. The package does ship its own storage for field definitions and values, so you still run its migrations once during installation.
- How do I attach custom fields to an existing Eloquent model?
- You add the package's trait or relationship to the model you want to extend, then register field definitions for that model through configuration or the package's data layer. Values are then accessible through familiar Eloquent relationships, so no custom query building is needed. The README shows the exact trait and relationship names to use.
- Which Laravel and PHP versions does escolalms/model-fields support?
- The package targets Laravel applications, but the overview here does not pin specific Laravel or PHP version constraints. Check composer.json in the repository for the authoritative illuminate/support and php requirements before upgrading. As a rule, match the package version to your Laravel major version.
- How are custom field values stored and retrieved with Eloquent?
- Each field definition is stored as data and linked to the owning model, while values are persisted in the package's own tables rather than as columns on your entity table. You read them through Eloquent relationships, so a model such as a course or user exposes its extra metadata like any other relation. That keeps retrieval familiar and avoids raw SQL.
- Can I change a custom field schema at runtime without breaking existing data?
- Yes, because definitions are data you can add fields without touching the database schema of the models you are extending. Changing or removing a definition is a data operation, so plan how existing stored values should be migrated or hidden before deleting it. Treat schema edits with the same care as any data migration.
- How do I test model fields in my Laravel test suite?
- Use the standard Laravel testing stack: build a model with the trait, create field definitions in your test setup, then assert the values come back through the relationship. If the package requires migrations, run RefreshDatabase or your usual test migration strategy. Factories for field definitions keep the tests readable.
- Is escolalms/model-fields suitable for production?
- It is designed to fit into existing Laravel applications, but every custom field value is an extra row and an extra relationship load, so eager-load fields where possible. On read-heavy listing pages, watch for N+1 queries when rendering many models with their custom fields. Test with realistic data volumes before a broad rollout.
- What are alternatives to escolalms/model-fields for custom fields in Laravel?
- Alternatives include storing JSON columns directly on your models, or other packages that manage meta tables and attribute casting. escolalms/model-fields is aimed at LMS-style entities where configuration should stay data-driven and extensible. Choose it when you need runtime-defined schemas rather than a fixed set of columns.
- Who maintains escolalms/model-fields and is it actively maintained?
- The package lives under the escolalms vendor namespace, which is tied to the Escola LMS ecosystem, so maintenance tends to follow that project's needs. Check the repository's release history and open issues before adopting it for a long-lived application. Pin a version and review changelogs when upgrading.