Download the PHP package seblhaire/daterangepickerhelper without Composer

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

DateRangePickerHelper

By Sébastien L'haire

DateRangePickerHelper is a Laravel library to provide an helper to initialize a single or double DateRangePicker calendar (based on jQuery Javascript framework). Dates use Nesbot Carbon on PHP side and Moment.js on Javascript side. Demo site available here.

Single date picker appears as follow:

And range date picker appears as follow:

Installation

  1. composer require seblhaire/daterangepickerhelper

  2. You can either download DateRangePicker on its website or install it with npmpackage manager if you compile your app Javascript files with Laravel Mix. Same choice for Bootstrap, jQuery and Moment. npm install jquery daterangepicker moment bootstrap.

  3. Composer will automatically link the package with Laravel. But you still can explicitely add provider and facade to your config/app.php:

  4. Publish package (optionally).

  5. Add style to your app.scss file:

  6. add to app.js

Usage

Declare Facade in Controller headers:

In a Controller function initialize object and pass it to the view. You can init several DateRangePickers in a view, but make sure that calendar id is unique.

Then in the Blade view, print your calendar like this:

{!! $calendar->output() !!} or {!! $calendar !!}

If $calendarElement is set to "mycal", the following line is printed, with options between rounded brackets:

Alternatively, you can init it in controller without variable assignation and use facade in view:

Controller:

View:

If your view contains only one DaterangePicker, you can omit calendar id:

Config File

Config file daterangepickerhelper.php is available, either in package directory in vendor/seblhaire/daterangepickerhelper or in your app config directory if you publish config. Parameters not language-dependent are in default section. Language-dependant parameters are in language section.

Parameters

Translation keys

Laravel loads config files very early in process. Therefore config files cannot contain __('translation.key'). In order to solve this issue, we made an helper either to print directly strings or to send translation key to translation helper. Translation keys can be delimited by character # Ex: "#formsbootstrap::messages.required#".

Feel free to translate keys in your own language and either to send it to the author or to do a merge request on GitHub.

Helpers

So far you have just initialized DateRangePickerHelper. But in your JS code, you need to retrieve new dates or date ranges set by your app user and/or to change dates dynamically, e.g. after you retrieve object from databases. DateRangePicker comes with methods to get and set new dates, but it is not easy to use, as shown here:

You have to remember the id of <div> tag that the DateRangePicker is attached to and to format dates with Moment syntax. However in most cases, you use DateRangePickerHelper with standard date format which has been already set in default options. Therefore we have set getters and setters.

Getters

By default, your DateRangePicker will be inserted in a form. Therefore, you can retrieve all form values e.g. with jQuery('form').serialize(). Alternatively, date can be retrieved by e.g. jQuery('#startdate').val(). If calendar is not in a form, date value can be retrieved by the complex statement above. No need to figure out how your calendar is set, DateRangePickerHelper comes with two getters:

These methods output the adequate JS statement to get a date according to your DateRangePickerHelper settings. In the following example, in your blade template, if your DateRangePickerHelper is passed to variable $calendar, you may retrieve dates this way:

You can also use facade to access these methods:

That's it.

Setters

On the other side, your Ajax queries may load information in forms and other objects. Both DateRangePicker and label next to calendar icon must be changed. We provide several methods for that purpose.

Method reset() resets the calendar with the initial values.

In the following example, in your blade template, if your DateRangePickerHelper is passed to variable $calendar, you may set dates this way:

With the Facade, use the followig methods. $calId parameter can be ommited if view has only one DateRangePicker.

Questions? Contributions?

Feel free to send feature requests or merge request to the author or simply to ask questions.


All versions of daterangepickerhelper with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
illuminate/http Version ^11.0
nesbot/carbon Version ^3.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 seblhaire/daterangepickerhelper contains the following files

Loading the files please wait ....