İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
function table_different_values($tableName) {
|
||||
$except = ['id', 'created_at', 'updated_at'];
|
||||
$key = 'table_different_values_' . $tableName;
|
||||
|
||||
if(Cache::has($key)) {
|
||||
$filterData = Cache::get($key);
|
||||
} else {
|
||||
$datas = db($tableName)->get()->toArray();
|
||||
$filterData = [];
|
||||
|
||||
foreach($datas AS $data) {
|
||||
|
||||
foreach($data AS $column => $value) {
|
||||
|
||||
if(!in_array($column, $except)) {
|
||||
|
||||
if(!isset($filterData[$column])) {
|
||||
$filterData[$column] = [];
|
||||
}
|
||||
|
||||
if(!in_array($value, $filterData[$column])) {
|
||||
$filterData[$column][] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Cache::put($key, $filterData);
|
||||
}
|
||||
|
||||
return $filterData;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user