Download the PHP package stillat/relationships without Composer

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

Entry Relationships

Entry Relationships provides a simple way to keep related Statamic entries in sync, automatically.

Overview

Entry relationships can help to dramatically simplify keeping related Entries in sync with each other.

For example, if you had a conferences collection that had a sponsored_by (containing a list of sponsors) field that needed to be kept in sync with a sponsors collection that contained a sponsoring field (containing a list of conferences that sponsor is sponsoring), the Entry Relationships addon lets you express this relationship like so:

Once a relationship has been created, Entry Relationships will leverage Statamic's entry events to keep things in sync automatically.

Relationships are also bi-directional. Updating the conference entries will automatically add the conference to any related sponsors. Updated the sponsors instead? No problem! Any conferences those sponsors are related to will also be updated!

Entry Relationships will keep track of and automatically apply the following types of updates:

How to Install

You can search for this addon in the Tools > Addons section of the Statamic control panel and click install, or run the following command from your project root:

How to Use

Made it past the introduction? Fantastic! Entry Relationships supports a number of relationship types, as well as provides a few helper commands.

Types of Relationships

Entry Relationships supports the following types of relationships:

Supported Data Entities

Entry Relationships supports the following data entities:

By default, Entry Relationships will assume that the relationship is between entries for backwards compatibility. To create a relationship between users and your entries, you will need to prefix the relationship with the data type to use when evaluating the relationship.

As an example, to create a relationship between a collection of conferences and the users who are managing those conferences, we could use something similar to the following:

Note that we only have to specify the field name when referencing users.

To create a Taxonomy Terms relationship, we must specify the entity type as well as the taxonomy name:

`

Creating a Many to Many Relationship

Example: Conferences can have many sponsors. Each sponsor can support many conferences.

To create a many to many relationship, you will need two collections. Each collection should contain an entries field, referencing the other collection. Both of these fields will need to allow multiple entries to be associated.

For example, assuming the following collection setup:

A conferences collection containing a sponsored_by field referencing the sponsors collection:

and a sponsors collection referencing the conferences collection:

The following relationship can be defined within your site's service provider (app/Providers/AppServiceProvider.php):

The manyToMany method will automatically define the inverse relationship for you. It is not necessary to define a many to many relationship from sponsors to conferences.

If you need to create multiple many-to-many relationships, you may choose to use set syntax, which providers a shortcut for defining multiple relationships. For example, to relate many collections to a taxonomy, you could use the following:

The above example will create a many-to-many relationship between the categories taxonomy and the field_name field, and is equivalent to the following:

Creating a One to Many Relationship

Example: Many books can be written by one author. Each author can write many books.

To create a many to one relationship, you will need two collections. Each collection should contain an entries field, referencing the other collection.

For this relationship, the collection that can be associated to a single other entry (books in this example) should have their entries field set to max_items: 1. The collection that can have many items associated with it (authors in this example) should have their entries field set to allow multiple associated entries.

Using a books collection referencing a single author:

and an authors collection referencing many books:

The following relationship can be defined within your site's service provider (app/Providers/AppServiceProvider.php):

The oneToMany method will automatically create the inverse manyToOne relationship for you. You do not need to create a relationship from authors.books to books.author.

Creating a Many to One Relationship

Example: An author can write many books. Each book is written by a single author.

This relationship is the inverse of the one to many relationship.

Using the same setup from the Creating a One to Many Relationship section, a many to one relationship can be defined like so:

When using the manyToOne method, you do not need to define the oneToMany inverse relationship from books.author to authors.books. This is done automatically for you.

Creating a One to One Relationship

Example: A job position may be held by a single employee. A single employee may only have one job at a time.

To create a many to one relationship, you will need two collections. Each collection should contain an entries field, referencing the other collection. Each field must contain the max_items: 1 configuration property.

Assuming an employees collection:

and a positions collection:

The following relationship can be defined within your site's service provider (app/Providers/AppServiceProvider.php):

You do not need to define the inverse relationship from positions.filled_by to employees.position. This is done automatically for you.

Other Things

Each relationship has a few properties that you can use to control how Entry Relationships handles them. These are:

These properties can be adjusted by calling their corresponding methods after defining the relationship:

Additionally, you can define your own relationships manually (but it is much easier to use one of the previously covered methods):

The automatic inverse relationships are not created when defining relationships manually.

Console Commands

The Entry Relationships addon provides a few console commands that can help simplify implementation and debugging.

The addon provides the following commands:

The relate:list Command

Running php please relate:list will display a table of all defined relationships:

The first column displays an index number for each relationship. It has no meaning other than to help relate automatically created inverse relationships.

You can limit the results returned to a single collection like so:

The relate:fill Command

This command can be used to force the Entry Relationships addon to check and update all related entries.

A common use case for this is when you already had a books collection and have associated their author. Later on, you add a books field to the authors collection. Running this command will bring the books and authors entries in sync for you.

The relate:fill command supports a few options:

Option Description
--dry Useful to see what entries would be updated, without actually updating them.
-v Adds the count of added, removed, and unchanged items to the output.
-vv Outputs the entry IDs when it performs an update.
-vvv Outputs everything.

You can limit the operation to a single collection like so:

License

Entry Relationships is free software released under the MIT License.


All versions of relationships with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
statamic/cms Version ^4.16 || ^5
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 stillat/relationships contains the following files

Loading the files please wait ....