You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 Added fixed cms
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
use App\Services\HousekeepingPermissionsService;
|
||||
use App\Services\PermissionsService;
|
||||
use App\Services\SettingsService;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
if (! function_exists('setting')) {
|
||||
function setting(string $setting): string
|
||||
{
|
||||
return app(SettingsService::class)->getOrDefault($setting);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('hasPermission')) {
|
||||
function hasPermission(string $permission): string
|
||||
{
|
||||
return app(PermissionsService::class)->getOrDefault($permission);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('hasHousekeepingPermission')) {
|
||||
function hasHousekeepingPermission(string $permission): string
|
||||
{
|
||||
return app(HousekeepingPermissionsService::class)->getOrDefault($permission);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('strLimit')) {
|
||||
function strLimit(string $string, int $limit, string $replacement = '...'): string
|
||||
{
|
||||
return Str::limit($string, $limit, $replacement);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('findMigration')) {
|
||||
function findMigration(string $tableName): string
|
||||
{
|
||||
foreach (glob(database_path('migrations/*.php')) as $filename) {
|
||||
$content = file_get_contents($filename);
|
||||
if ($content !== false && str_contains($content, "Schema::create('$tableName'")) {
|
||||
return basename($filename);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('columnExists')) {
|
||||
function columnExists(string $table, string $column): bool
|
||||
{
|
||||
return Schema::hasColumn($table, $column);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('dropForeignKeyIfExists')) {
|
||||
function dropForeignKeyIfExists(string $table, string $column): void
|
||||
{
|
||||
$connection = Schema::getConnection();
|
||||
$tableWithPrefix = $connection->getTablePrefix() . $table;
|
||||
|
||||
$foreignKeys = collect($connection->select('SELECT CONSTRAINT_NAME
|
||||
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = ?
|
||||
AND COLUMN_NAME = ?', [$tableWithPrefix, $column]))
|
||||
->pluck('CONSTRAINT_NAME');
|
||||
|
||||
foreach ($foreignKeys as $foreignKey) {
|
||||
if (! empty($foreignKey)) {
|
||||
$connection->statement("ALTER TABLE {$table} DROP FOREIGN KEY {$foreignKey}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user