Download the PHP package pion/laravel-support-eloquent without Composer

On this page you can find all versions of the php package pion/laravel-support-eloquent. 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-support-eloquent

Laravel's Eloquent support package

Contains a set of traits for the eloquent model. In future can contain more set of classes/traits for the eloquent database.

Installation

composer require pion/laravel-support-eloquent

Attribute value altering traits

Set of traits that will change the attribute value.

CleanHTMLFromAttributeTrait

Enables automatic attribute value cleaning from HTML for all attributes, by limiting only desired by $cleanAttributes property or by limiting which attributes can have html $dontCleanAttributes. You can use the $stripHtmlTags property to specify tags which should not be stripped.

For manual usage use CleanHTMLTrait with tryToCleanAttributeValue($key, $value) method.

Null only given attributes:

Don't null provided attributes:

NullEmptyStringAttributeTrait

Enables the automatic nulling of empty string value (like from post or set). You can provide list of columns keys to allow only specified columns (use $nullEmptyAttributes) to be set to null or you can provide a list of columns keys to ignore while trying to null the value (use $dontNullEmptyAttributes). They can be set in construct or as property.

For manual usage use NullEmptyStringTrait with tryToNullAttributeValue($key, $value) method.

Null only given attributes:

Don't null provided attributes:

NormalizeFloatAttributeTrait

Converts float string to float value with comma support (floatval fails to convert 13,3 to 13.3) by setting list of attributes via $normalizeFloatAttributes.

For manual usage use NormalizeFloatTrait with tryToNormalizeFloatAttributeValue($key, $value) method.

DateAttributeValueTrait

Converts allowed attributes (by settings $dateAttributes) to carbon instance without any format limitation. Tries to parse any format.

For manual usage use DateAttributeTrait with tryToConvertAttributeValueToDate($key, $value) method.

All values are converted via toArray method to default format. You can customize date formats by attribute by setting dateFormats:

Running multiple trait functions

Using all attributes traits

To apply all traits that are currently implemented use AlterAttributeValueTrait.

Manual

Unfortunately traits can't override same method (in this case setAttribute). For this purpose, you must override the setAttribute method by your self and call the desired trait method by your self.

Every trait has own manual method that tries to alter the value. Use appropriate trait (NullEmptyStringTrait, CleanHTMLTrait, etc).

For chaining the value you can use helper function alter_attribute_value.

Relation Traits

RelationJoinTrait

Enables to create a join SQL statement that will construct the relation model and stores it into relations (so you don't need to eager load the relation). The model is created from the relation function (the key you provide). You can create a custom aliases to fix custom relation naming.

In default usage will load all columns from schema, for better perfomance you can provide a set of columns to load from the relation. You can't provide a '*' as column.

$relationAliases - A list of relations that has different method name than the table.

Can be defined in model like this:

Then you can call it in standard way modelJoin("type") for a ActivityType model class.

Example

The basic method support custom columns, where condition, join operator and join type.

All columns
Desired columns (recommended)

Then you can get the object by standard relation way:

But be carefull, can be null (default is LEFT connection)!

Desired columns with inner join
Method

Docs is provided in code.

Advanced example

Docs is provided in code. Uses table as a relation function.

RelationCountTrait

Enables to count a related models. In future will prepare better docs.

Example

Usage of where:

Calling the function again will use the cache in relations array. After this call you can also use

You can also get the where index by passing variable which will be overided by the reference:

Simple call will return count and the index will be stored in $model->user


All versions of laravel-support-eloquent with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version ^6 || ^7 || ^8 || ^9 || ^10
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 pion/laravel-support-eloquent contains the following files

Loading the files please wait ....