Download the PHP package erikgall/listify without Composer

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

Listify

Turn any Eloquent model into a list!

Description

This project was originally created by Travis Vignon but is no longer maintained and only supported Laravel 5. This fork of the project provides support for Laravel 7 & 8 applications and will be updated as new Laravel versions are released. Please feel free to send in contributions and help keep this package up to date!

Listify provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a position column defined as an integer on the mapped database table. Listify is an Eloquent port of the highly useful Ruby gem acts_as_list (https://github.com/swanandp/acts_as_list).

Requirements

Installation

Install Listify into your Laravel 8 application with composer:

The Laravel 7 branch can be found here erikgall/listify:2.x

To install Listify into your Laravel 7 application with composer:

Quickstart

First things first, you'll need to add a column to store the position. From the command line, use the migration generator:

{table_name} is a required argument. {position_column_name} is optional and the default value is "position".

Then, in your model:

Make sure that the initListify() method is called after parent::__construct() of your model.

That's all it takes to get access to the Listify hotness.

Overview

Instance Methods Added To Eloquent Models

You'll have a number of methods added to each instance of the Eloquent model to which Listify is added.

In Listify, "higher" means further up the list (a lower position), and "lower" means further down the list (a higher position). That can be confusing, so it might make sense to add tests that validate that you're using the right method given your context.

Methods That Change Position and Reorder List

Methods That Change Position Without Reordering List Immediately

Note: a changed position will still trigger updates to other items in the list once the model is saved

Methods That Return Attributes of the Item's List Position

Configuration

There are a few configuration options available. You'll need to pass these in as an array argument for initListify() in your model's constructor. Here are the options:


String

If string is passed in, a raw string is passed in as a whereRaw to the scope. This allows you to do something like 'custom_foreign_key = 42' and have all of the items scoped to that result set. You can pass as complicated of a where clause as you want, and it will be passed straight into each DB operation.

Example:

Results in a scope of:

WHERE answer_to_ltuae = 42


Illuminate\Database\Eloquent\Relations\BelongsTo

If Illuminate\Database\Eloquent\Relations\BelongsTo is passed in, Listify will match up the foreign key of the scope to the value of the corresponding foreign key of the model instance.

Example:

Results in a scope of:

WHERE to_do_list_id = {{value of toDoListItem.to_do_list_id}}


Illuminate\Database\Query\Builder

And lastly, if Illuminate\Database\Query\Builder is passed in, Listify will extract the where clause of the builder and use it as the scope of the Listify items. This scope type was added in an attempt to keep parity between the acts_as_list version and Listify; however, due to differences in the languages and in ActiveRecord versus Eloquent, it is a limited implementation so far and needs impovement to be more flexible and secure. This is a big limitation and will be the first thing addressed in upcoming releases.

This one is tricky, because in order for it to work the query objects where array is prepared with the bindings outside of PDO and then passed in as a raw string. So, please keep in mind that this route can open your application up to abuse if you are not careful about how the object is built. If you use direct user input, please sanitize the data before using this as a scope for Listify.

Example:

Results in a scope of:

to_do_list_items.type = 'Not A List of My Favorite Porn Videos'


Changing the configuration

You may also change any configuration value during runtime by using any of the setters on the Config class. $this->listifyConfig->('key', 'value');`. For example, to change the scope, you can do this:

When an update is processed, the original scope will be used to remove the record from that list, and insert it into the new list scope. Be careful here. Changing the configuration during processing can have unpredictable effects.

You may also change the other config values. The setters are chainable.

Notes

All position queries (select, update, etc.) inside trait methods are executed without the default scope, this will prevent nasty issues when the default scope is different from Listify scope.

The position column is set after validations are called, so you should not put a presence validation on the position column.

Future Plans

Aside from that, I hope to just keep in parity with the Ruby gem acts_as_list (https://github.com/swanandp/acts_as_list) as necessary.

Contributing to Listify

Copyright

Copyright (c) 2020 Erik Galloway, released under the MIT license


All versions of listify with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
illuminate/database Version ^8.0
illuminate/support Version ^8.0
illuminate/console Version ^8.0
illuminate/events Version ^8.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 erikgall/listify contains the following files

Loading the files please wait ....