Download the PHP package lexbelcode/laravel-eloquent-dynamic-tables-for-models without Composer

On this page you can find all versions of the php package lexbelcode/laravel-eloquent-dynamic-tables-for-models. 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-eloquent-dynamic-tables-for-models

Laravel Eloquent Dynamic Tables for Models

A simple but effective way to set the table of a model at runtime and continue using Eloquent instead of QueryBuilder

Installation

The package can be installed via Composer:

composer require lexbelcode/laravel-eloquent-dynamic-tables-for-models

Description

Consider this scenario:

You have, for any razon, a database in which exists A) tables with different names but same structure, or you need break a really big table into smallers and you don't want to use the partitioning provided by your database, and B) tables with different names but same structure that has a relationship with the tables in A)

Example: In general, if you have one model for sells and one model for buyers, and you need to get records from the sells table with the realted data from buyers, using Eloquent you will do this:

But if the scenario changes and you have to divide your tables into multiples like this: sells_01 sells_02 sells_03 sells_04

buyers_01 buyers_02 buyers_03 buyers_04

Your models are the same, but if you need to get data from sells_03 with the realted data from buyers_03 you can't use Eloquent like before, because your Sell model is pointed to the sells table and your Buyer model is pointed to the buyers table, so, the only way to get the data is through the QueryBuilder or raw querys using joins, and you will lost the magic of Eloquent, inclusive, if you have Eloquent events, you won't be able to fire them because of this

But if you update your models, to extend from the LaravelEloquentDynamicModel class, you can do it as simple as this:

Your models:

And in your code, you only have to add this two lines of code:

And during the time execution of the related PHP script, model Sell will be pointing to sells_03 table and model Buyer will be pointing to buyers_03 table, and you'll can use Eloquent normaly with that models, relationships, events, etc.

Requirements

Author

Alex Beltrán Follow me on X as @LexBelCode


All versions of laravel-eloquent-dynamic-tables-for-models with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^10.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 lexbelcode/laravel-eloquent-dynamic-tables-for-models contains the following files

Loading the files please wait ....