Download the PHP package jackiedo/timezonelist without Composer
On this page you can find all versions of the php package jackiedo/timezonelist. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jackiedo/timezonelist
More information about jackiedo/timezonelist
Files in jackiedo/timezonelist
Package timezonelist
Short Description A small package use to create a timezone list box in Laravel
License MIT
Informations about the package timezonelist
Laravel Timezone List
Overview
- Laravel Timezone List
- Overview
- Feature
- Versions and compatibility
- Documentation
- Installation
- Step 1 - Require Package
- Step 2 - Register Service Provider
- Step 3 - Register Facade Alias
- Usage
- Working With Facade
- Using As Regular Class
- Available Methods
- Render a timezone listbox
- Render a timezone array
- Filter the returned list
- Get only some specified groups
- Exclude some specified groups
- Change the layout of the returned list
- Decide whether to split group or not
- Decide whether to show the timezone offset or not
- Reset all config and return new list
- Contributors
- License
Feature
- Render a timezone listbox (select element) in Laravel
- Render a timezone array in Laravel
Versions and compatibility
Currently, there are some branches of Timezone-List is compatible with the following version of Laravel framework
Timezone-List branch | Laravel version |
---|---|
4.x | 4.x |
5.x | 5.x and later |
This documentation is use for branch 5.x
Documentation
Installation
You can install this package through Composer with the following steps:
Step 1 - Require Package
At the root of your application directory, run the following command (in any terminal client):
Note: Since Laravel 5.5, service providers and aliases are automatically registered. But if you are using Laravel 5.4 and earlier, you must register the Service Provider and the Facade manually. Do the following steps:
Step 2 - Register Service Provider
Open config/app.php
, and add a new line to the providers section:
Step 3 - Register Facade Alias
Add the following line to the aliases section in file config/app.php
:
Usage
Working With Facade
Laravel Timezone List has a facade with the fully qualified namespace is Jackiedo\Timezonelist\Facades\Timezonelist
. You can perform all operations through this facade.
Example:
Note: If at the installation step, you have registered the Facde alias, then in the areas where the namespace is not used, eg views..., you can completely use that Facde alias to use instead of having to use the fully qualified Facde namespace.
Example: (use in the resources/views/demo.blade.php
file)
Using As Regular Class
You can completely use the package through the Jackiedo\Timezonelist\Timezonelist
class like using a regular object class.
Example:
Available Methods
Render a timezone listbox
Syntax:
Note: the
create()
method will be removed in the version 6.x
Example:
This will output the following HTML code:
The
Timezonelist::toSelectBox()
method has four parameters:
- The first parameter is required, it is the name attribute of the rendered select tag
- The second parameter use to set selected value of list box.
- The third parameter use to set HTML attribute of select tag.
- The fourth parameter allow to use some HTML entities in the rendered select tag. The purpose is to make the element look better.
Example:
Example of the difference of the
fourth parameter
Render a timezone array
Syntax:
Example:
Filter the returned list
By default, the toSelectBox
, toArray
... methods will return a list of timezones consisting of 11 groups (one common group and 10 groups corresponding to the continents):
- General
- Africa
- America
- Antarctica
- Arctic
- Asia
- Atlantic
- Australia
- Europe
- Indian
- Pacific
In some cases, we don't want to get in that list some specified groups, we can do that by some of the following methods:
Get only some specified groups
Syntax:
Example:
Exclude some specified groups
Syntax:
Example:
Change the layout of the returned list
In some cases, we need to change the form of the list that we will receive, we can do it through some of the following methods:
Decide whether to split group or not
Syntax:
Example:
Decide whether to show the timezone offset or not
Syntax:
Example:
Reset all config and return new list
Always keep in mind that, if we use package methods via Facade, we are using it as a static
interface to a class. This means that the filter and layout settings will always be saved for the next call. If we don't want to reuse these settings, we have to execute the following method on the next call:
Syntax:
Example:
Contributors
This project exists thanks to all its contributors.
License
MIT © Jackie Do