Files
citrus-cms/app/Functions/table-columns.php
T
2026-04-28 21:14:25 +03:00

28 lines
805 B
PHP

<?php
use Illuminate\Support\Facades\Schema;
function table_columns($tableName) {
$prefix = 'table_columns_' . $tableName;
if(Cache::has($prefix)) {
$columnNames = Cache::get($prefix);
} else {
$exceptsColumns = ['created_at', 'updated_at'];
$columnNames = array_diff(Schema::getColumnListing($tableName), $exceptsColumns);
Cache::put($prefix, $columnNames);
}
return $columnNames;
}
function table_column_type($tableName, $columnName) {
$prefix = 'table_column_type_' . $tableName . $columnName;
if(Cache::has($prefix)) {
$columnType = Cache::get($prefix);
} else {
$columnType = Schema::getColumnType($tableName, $columnName);
Cache::put($prefix, $columnType);
}
return $columnType;
}
?>