Download the PHP package fiachehr/laravel-eav without Composer

On this page you can find all versions of the php package fiachehr/laravel-eav. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-eav

Laravel EAV Package

A complete and powerful Entity-Attribute-Value (EAV) package for Laravel.

Documentation

Laravel EAV — Documentation (hosted on fiachehr.ir)

Features

Requirements

Installation

After installation, publish and run the migrations:

Usage

1. Use the Trait in Your Models

2. Working with Attributes

2.1. Getting Attribute Values

2.2. Setting Attribute Values

3. Validation System

You can apply validations to attributes to ensure data integrity. Validations are applied based on the attribute type.

3.1. Setting Validations

3.2. Validating Attribute Values

3.3. Getting Laravel Validation Rules

4. Multilingual Support

The package provides built-in multilingual support for attributes and attribute groups. Each attribute and attribute group has a language field that stores the language code (e.g., 'en', 'fa', 'de').

4.1. Creating Attributes with Language

4.2. Filtering by Language

Using Model Scopes
Using Repository Methods

4.3. Translation System

The package includes a built-in translation system using the eav_translations table. This allows you to store translations for attribute fields (like title and description) in multiple languages.

Using the HasTranslations Trait

To enable translations for your Attribute or AttributeGroup models, use the HasTranslations trait:

Getting Translations
Setting Translations
Deleting Translations
Using with Custom Models

If you extend EloquentAttribute in your project, the translation system automatically uses the base class name for compatibility:

Database Structure

Translations are stored in the eav_translations table:

Note: The translation system uses polymorphic relations, so it works seamlessly with models that extend EloquentAttribute or use the trait directly.

4.4. Working with Multilingual Attributes in Models

4.5. Language Configuration

Make sure your Laravel application has the locale configured:

The package will automatically use app()->getLocale() for the forCurrentLanguage() scope.

5. Advanced Search and Filtering

5.1. Using Model Scopes

5.2. Using Query Builder (Recommended for Complex Queries)

5.3. Text Search Methods

5.4. Number Search Methods

5.5. Decimal Search Methods

5.6. Date/Time Search Methods

5.7. Boolean Search Methods

5.8. JSON Search Methods

5.9. Multiple Conditions

5.10. Ordering and Sorting

5.11. Pagination and Limits

5.12. Getting Results

5.13. Selecting Specific Attributes

5.14. Aggregate Functions

6. Working with Attribute Groups

7. Available Attribute Types

The package supports 20+ attribute types with a flexible validation system:

Text Types

Number Types

Selection Types

Date/Time Types

Boolean Types

File Types

Location Types

7.1. Validation System

Instead of having separate types for Email, URL, Image, Video, etc., you can use the validation system to apply specific validations to base types:

Example:

Available Validations:

8. Database Optimization

The package uses an optimized database structure with separate columns for different data types:

This structure allows for:

9. Real-World Examples

Example 1: E-commerce Product Search

Example 2: User Profile Filtering

Example 3: Content Management

10. Using Repositories

11. Using Use Cases

Testing

The package includes a comprehensive test suite with 126 tests covering all features.

Running Tests

Test Coverage

For detailed test documentation, see tests/README.md.

Configuration

Publish the config file:

This will create a config/laravel-eav.php file where you can customize table names and cache settings.

Migrations

Run the migrations to create the necessary tables:

The package includes the following migrations:

Performance Tips

  1. Use Indexes: The package automatically creates indexes on value columns for fast searches.

  2. Eager Loading: Always eager load attributes when querying multiple entities:

  3. Select Specific Attributes: Only load the attributes you need:

  4. Use Query Builder for Complex Searches: For complex queries with multiple conditions, use the Query Builder instead of multiple scopes:

Troubleshooting

Attribute values not saving correctly

Make sure you're using the correct data type for the attribute. The package automatically stores values in the appropriate column based on the attribute type.

Slow queries

Migration errors

If you're updating from an older version, make sure to run the update migration:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

Version 1.0.0

Support

For issues and questions, please open an issue on GitHub.

License

MIT


Made with ❤️ by Fiachehr Pourmojib


All versions of laravel-eav with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fiachehr/laravel-eav contains the following files

Loading the files please wait ...