Package Data | |
---|---|
Maintainer Username: | edujugon |
Maintainer Contact: | edujugon@gmail.com (Eduardo Marcos) |
Package Create Date: | 2016-10-17 |
Package Last Update: | 2017-02-14 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:21:30 |
Package Statistics | |
---|---|
Total Downloads: | 21 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This package provides useful features to give extra functionality to your Laravel project.
type in console:
composer require edujugon/laravel-extra-features
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.
Functionality
Traits
Services
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.
config/extrafeatures.php
file and update the value for the key REDIRECT_NO_PAGE_FOUND
.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.
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)
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)
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)
$array = [
'<'=>['pvr'=>'pvl'],
'like'=>['id_imagen'=>'"%5047%"'],
'null'=>['margen_1']
];
QueryCreator::dynamic('products',$array)->select('id','id_imagen')->first());