PHPackages                             edujugon/laravel-extra-features - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. edujugon/laravel-extra-features

ActiveLibrary

edujugon/laravel-extra-features
===============================

This package provides useful features to give extra functionality to your Laravel project

v1.0.2(9y ago)321MITPHP

Since Oct 21Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Edujugon/LaravelExtraFeatures)[ Packagist](https://packagist.org/packages/edujugon/laravel-extra-features)[ RSS](/packages/edujugon-laravel-extra-features/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Laravel Extra Features
======================

[](#laravel-extra-features)

This package provides useful features to give extra functionality to your Laravel project.

Installation
------------

[](#installation)

type in console:

```
composer require edujugon/laravel-extra-features

```

Laravel 5.\*
------------

[](#laravel-5)

Register the package service by adding it to the providers array.

> IMPORTANT! Ensure you put that line at the end of the providers list.

```
'providers' => array(
    ...
    Edujugon\LaravelExtraFeatures\Providers\LaravelExtraFeaturesServiceProvider::class
)

```

Publish the package's configuration file to the application's own config directory

```
php artisan vendor:publish  --tag=ExtraFeaturesConfig

```

The above line will create a file called `extrafeatures.php` under config folder.

Feature List
------------

[](#feature-list)

**Functionality**

- [Redirect when No Page Found](https://github.com/edujugon/LaravelExtraFeatures#redirect-no-page-found)
- [Carbon Locale](https://github.com/edujugon/LaravelExtraFeatures#carbon-locale)

**Traits**

- [DateScopesTrait](https://github.com/edujugon/LaravelExtraFeatures#datescopestrait)

**Services**

- \[QueryCreator\](

### Redirect No Page Found

[](#redirect-no-page-found)

When user tries to load an unknown url, it's redirected to a specific known url.

> !IMPORTANT, This feature won't work for local environment. That's an intended behaviour no to hide any redirect/request error.

- Go to `config/extrafeatures.php` file and update the value for the key `REDIRECT_NO_PAGE_FOUND`.

### Carbon Locale

[](#carbon-locale)

Carbon language is set based on the laravel's app locale. By default it is enabled. You may disable changing `CARBON_LOCALE` value to `false`in `config/extrafeatures.php` file.

### DateScopesTrait

[](#datescopestrait)

Provide extra features on year, month and day to retrieve data for Laravel Eloquent.

> Adding $dateColumn as model class's property you don't need to pass the $dateColumn parameter to the methods.

```
    /**
     * Get items of passed year
     * If no year, returns Items of current year
     *
     * @param $query
     * @param $column
     * @param null $year
     * @return mixed
     */
    public function scopeYear($query,$dateColumn = null,$year = null)
```

```
    /**
     * Get items of passed month
     * If no month, take current month
     * If no year, take current year
     *
     * @param $query
     * @param $column
     * @param null $month
     * @param null $year
     * @return mixed
     */
    public function scopeMonth($query,$dateColumn = null,$month = null,$year = null)
```

```
    /**
     * Get items of passed day.
     * If no day, take current day
     * If no month, take current month
     * If no year, take current year
     *
     * @param $query
     * @param $column
     * @param null $day
     * @param null $month
     * @param null $year
     * @return mixed
     */
    public function scopeDay($query,$dateColumn = null,$day = null, $month = null, $year = null)
```

### QueryCreator

[](#querycreator)

Create DB query dynamically

```
    /**
         * Create a query dynamically with passed parameters.
         *
         * Params:
         *  tableName is the table name.
         *  array is a list of data to be converted to query.
         *
         * @param $tableName
         * @param array $array
         * @return mixed
         */
        static public function dynamic($tableName, array $array)
```

#### API list

[](#api-list)

- [table](https://github.com/edujugon/LaravelExtraFeatures#table)
- [build](https://github.com/edujugon/LaravelExtraFeatures#build)

##### Table

[](#table)

`table` method sets the table name for the Query.

**Syntax**

```
object table($tableName)
```

\#####Build

`build` method builds the query based on passed array.

**Syntax**

```
object build(arrray $data)
```

#### Use Cases

[](#use-cases)

```
$array = [
            '
