File: /home/imensosw/www/ezwork/app/Models/Language.php
<?php
/**
* LanguageModel class file
*
* PHP Version 7.2
*
* @category Model
* @package Ez
* @author Imenso Software <admin@imensosoftware.com>
* @license http://imensosoftware/license.php GNU Public License
* @link http://imensosoftware.com/recipes
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* LanguageModel class
*
* The class manage Language related queries
*
* @category LanguageModel
* @package Ez
* @author Imenso Software <admin@imensosoftware.com>
* @license http://imensosoftware/license.php GNU Public License
* @link http://imensosoftware.com/recipes
*/
class Language extends Model
{
public $table = "languages";
public $fillable = ['language_l','language_s','so'];
public $timestamps = false;
/**
* GetLanguageCombination function make a language combination and
* return the language combination.
*
* @param int chars
* @param int size
* @param array combinations
* @return language combination array
*/
public static function getLanguageCombination($chars, $size, $combinations = array())
{
// if it's the first iteration, the first set
// of combinations is the same as the set of characters
if (empty($combinations)) {
$combinations = $chars;
}
// we're done if we're at size 1
if ($size == 1) {
return $combinations;
}
// initialise array to put new values in
$new_combinations = array();
// loop through existing combinations and character set to create strings
foreach ($combinations as $combination) {
foreach ($chars as $char) {
if ($combination != $char) {
$new_combinations[] = [$combination,$char] ;
}
}
}
// call same function again for the next iteration
return self::getLanguageCombination($chars, $size - 1, $new_combinations);
}
}