JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "AddsIndexToExistingTable.php"

Full Path: /home/markqprx/iniasli.pro/Traits/AddsIndexToExistingTable.php
File size: 615 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace Common\Database\Traits;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

trait AddsIndexToExistingTable
{
    protected function addIndexIfDoesNotExist(Blueprint $table, string $column) {
        $prefix = Schema::getConnection()->getTablePrefix();
        $sm = Schema::getConnection()->getDoctrineSchemaManager();
        $tableName = "{$prefix}{$table->getTable()}";
        $indexesFound = $sm->listTableIndexes($tableName);
        if (!array_key_exists("{$tableName}_{$column}_index", $indexesFound)) {
            $table->index($column);
        }
    }

}