Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Run complex SQL queries from API requests such as update different conditional records in a single query and etc

Notifications You must be signed in to change notification settings

rakibdevs/laravel-query-extra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✔ Contribute to improve the package! Thanks in advance.

Laravel Query Extra

GitHub stars GitHub forks GitHub issues GitHub license

Run complex SQL queries from API requests such as update different conditional records in a single query.

Installation

Install the package through Composer. On the command line:

composer require rakibdevs/laravel-query-extra

Configuration

If Laravel > 7, no need to add provider

Add the following to your providers array in config/app.php:

'providers' => [
    // ...
    RakibDevs\QueryExtra\QueryExtraServiceProvider::class,
];

Usage

Suppose we need to update categories table when cat_id 3 then cat_name will be 'Category 3' and cat_id 4 then cat_name will be 'Category 4' and so on...

To update multiple records in a single query,

$arrr = array(
	    array(
		'data' => array(
		    'cat_name' => 'Category 3', // column name
	            'status' => 1 		// column name
		),
		'keyval' => 3 	// column value for whereKey() condition
	    ),
	    array(
		'data' => array(
		    'cat_name' => 'Category 2', // column name
	            'status' => 1 		// column name
		),
		'keyval' => 2 	// column value for whereKey() condition
	    ),
	    array(
	        .......................
	        .......................
	);
use RakibDevs\QueryExtra\QueryExtra;


(new QueryExtra)
    ->table('categories') // add table name
    ->whereKey('cat_id')  // key which apply the condition
    ->bulkup($arrr);      // updated array

Note: 'data' of all items must have same columns.

License

Laravel Open Weather API is licensed under The MIT License (MIT).

About

Run complex SQL queries from API requests such as update different conditional records in a single query and etc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages