mardi 10 octobre 2017

Laravel and MySQL SHOW TABLES

I'm using Laravel Translatable package. I want to get all tables names that suffixed with the term _translations. I have tried the following:

public function getTranslatableModels()
    {
        $tables = DB::select('SHOW TABLES LIKE "%_translations"');
....

The print out of dd($tables) is like:

array:2 [▼
  0 => {#779 ▼
    +"Tables_in_factory2 (%_translations)": "defect_translations"
  }
  1 => {#778 ▼
    +"Tables_in_factory2 (%_translations)": "defgroup_translations"
  }
]

The problem is that I could not able to get the resultant tables' names using a loop. In other words I could not able to find a suitable key. i.e:

foreach ($tables as $table){
    // $table->OfWAHT
}

So, is there any way in MySQL to do the above query to return an accessible key for the table name? Or is there any other thing in Eloquent for example?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire