Download the PHP package eloverde-sistemas/landlord without Composer

On this page you can find all versions of the php package eloverde-sistemas/landlord. 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 landlord

Landlord for Laravel & Lumen 5.2+

StyleCI Status
Build Status

A single database multi-tenancy package for Laravel & Lumen 5.2+.

Upgrading from Landlord v1? Make sure to read the change log to see what needs updating.

Installation

To get started, require this package:

Laravel

Add the ServiceProvider in config/app.php:

Register the Facade if you’d like:

You could also publish the config file:

and set your default_tenant_columns setting, if you have an app-wide default. LandLord will use this setting to scope models that don’t have a $tenantColumns property set.

Lumen

You'll need to set the service provider in your bootstrap/app.php:

And make sure you've un-commented $app->withEloquent().

Usage

This package assumes that you have at least one column on all of your Tenant scoped tables that references which tenant each row belongs to.

For example, you might have a companies table, and a bunch of other tables that have a company_id column.

Adding and Removing Tenants

IMPORTANT NOTE: Landlord is stateless. This means that when you call addTenant(), it will only scope the current request.

Make sure that you are adding your tenants in such a way that it happens on every request, and before you need Models scoped, like in a middleware or as part of a stateless authentication method like OAuth.

You can tell Landlord to automatically scope by a given Tenant by calling addTenant(), either from the Landlord facade, or by injecting an instance of TenantManager().

You can pass in either a tenant column and id:

Or an instance of a Tenant model:

If you pass a Model instance, Landlord will use Eloquent’s getForeignKey() method to decide the tenant column name.

You can add as many tenants as you need to, however Landlord will only allow one of each type of tenant at a time.

To remove a tenant and stop scoping by it, simply call removeTenant():

You can also check whether Landlord currently is scoping by a given tenant:

And if for some reason you need to, you can retrieve Landlord's tenants:

Setting up your Models

To set up a model to be scoped automatically, simply use the BelongsToTenants trait:

If you’d like to override the tenants that apply to a particular model, you can set the $tenantColumns property:

Creating new Tenant scoped Models

When you create a new instance of a Model which uses BelongsToTenants, Landlord will automatically add any applicable Tenant ids, if they are not already set:

Querying Tenant scoped Models

After you've added tenants, all queries against a Model which uses BelongsToTenant will be scoped automatically:

Note: When you are developing a multi tenanted application, it can be confusing sometimes why you keep getting ModelNotFound exceptions for rows that DO exist, because they belong to the wrong tenant.

Landlord will catch those exceptions, and re-throw them as ModelNotFoundForTenantException, to help you out :)

If you need to query across all tenants, you can use allTenants():

Under the hood, Landlord uses Laravel's anonymous global scopes. This means that if you are scoping by multiple tenants simultaneously, and you want to exclude one of the for a single query, you can do so:

Contributing

If you find an issue, or have a better way to do something, feel free to open an issue or a pull request.


All versions of landlord with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
illuminate/support Version >=5.4
illuminate/database Version >=5.6
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 eloverde-sistemas/landlord contains the following files

Loading the files please wait ....