Download the PHP package jlorente/laravel-eloquent-splitted-dates-trait without Composer

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

Laravel Eloquent Model Splitted Dates Trait

A Laravel Trait for Eloquent Models to handle date fields that are stored both in the date field itself and in separate field components such as year, month, day, hour, etc...

Installation

The preferred way to install this extension is through composer.

With Composer installed, you can then install the extension using the following commands:

or add

to the section of your composer.json file.

Usage

Basic Configuration

To enable and configure splitted dates fields in an Eloquent Model use the Jlorente\Laravel\Eloquent\Concerns\SplittedDates\HasSplittedDates Trait on the model and define the splittedDates array with the date fields you want to store splitted.

In the example, the "begin_at" date will be stored splitted in the fields "begin_at_year", "begin_at_month" and "begin_at_day". Everytime the "begin_at" field is set, the other fields will be set also and vice versa.

If one of the splitted components is null, the main attribute "begin_at" correspondent component will be set to to 1 in case of month and day properties, 0 in case of time properties or the current year in case of year property.

All the attributes defined in the splittedDates array will be treated as defined in the date mutator property so you can set its value to a UNIX timestamp, date string (Y-m-d), date-time string, or a DateTime / Carbon instance.

Remember that the database table must have the correspondent columns "_year", "_month" and "_day" to store the splitted date value.

Advanced Configuration

The default configuration for splitted dates is to map the date value to a year, month and day field, but you can map the value to whatever carbon unit you want (year, month, day, hour, minute, second, milli, millisecond, micro, microsecond).

To configure the splitted date with other units than the default ones define which ones do you want to store on splittedDates property definition.

Doing so, the properties "begin_at_hour" and "begin_at_minute" will be set everytime the "begin_at" field is set and vice versa.

Further considerations

The trait does not validate dates when setting the splitted fields, so it is possible that date overflows ocurr if you set an invalid value for a date.

License

Copyright © 2019 José Lorente Martín [email protected].

Licensed under the BSD 3-Clause License. See LICENSE.txt for details.


All versions of laravel-eloquent-splitted-dates-trait with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
illuminate/support Version >=5.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 jlorente/laravel-eloquent-splitted-dates-trait contains the following files

Loading the files please wait ....