Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
2
vendor/aiz-packages/combination-generate/README.md
vendored
Normal file
2
vendor/aiz-packages/combination-generate/README.md
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# combination-generate
|
||||
Generate combinations of items in multiple arrays
|
||||
26
vendor/aiz-packages/combination-generate/composer.json
vendored
Normal file
26
vendor/aiz-packages/combination-generate/composer.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "aiz-packages/combination-generate",
|
||||
"description": "Generate combinations of items in multiple arrays",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"AizPackages\\CombinationGenerate\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Shifat Hossain",
|
||||
"email": "amithassan3229@gmail.com"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"require": {},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"AizPackages\\CombinationGenerate\\Providers\\CombinationServiceProvider"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
31
vendor/aiz-packages/combination-generate/src/Providers/CombinationServiceProvider.php
vendored
Normal file
31
vendor/aiz-packages/combination-generate/src/Providers/CombinationServiceProvider.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace AizPackages\CombinationGenerate\Providers;
|
||||
|
||||
use AizPackages\CombinationGenerate\Services\CombinationService;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class CombinationServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(CombinationService::class, function ($app) {
|
||||
return new CombinationService();
|
||||
});
|
||||
}
|
||||
}
|
||||
35
vendor/aiz-packages/combination-generate/src/Services/CombinationService.php
vendored
Normal file
35
vendor/aiz-packages/combination-generate/src/Services/CombinationService.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace AizPackages\CombinationGenerate\Services;
|
||||
|
||||
class CombinationService {
|
||||
|
||||
public function generate_combination($arrays, $i=0)
|
||||
{
|
||||
if (!isset($arrays[$i])) {
|
||||
return array();
|
||||
}
|
||||
if ($i == count($arrays) - 1) {
|
||||
$result = array();
|
||||
foreach ($arrays[$i] as $v) {
|
||||
$result[][] = $v;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
// get combinations from subsequent arrays
|
||||
$tmp = $this->generate_combination($arrays, $i + 1);
|
||||
|
||||
$result = array();
|
||||
|
||||
// concat each array from tmp with each element from $arrays[$i]
|
||||
foreach ($arrays[$i] as $v) {
|
||||
foreach ($tmp as $t) {
|
||||
$result[] = is_array($t) ?
|
||||
array_merge(array($v), $t) :
|
||||
array($v, $t);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user