Search code examples
mysqllaravel-4eloquent

Get MySQL table columns using Eloquent in Laravel


How would I get inside of a custom model the columns for a specific MySQL table using Eloquent in Laravel

I was trying DB::query("SHOW COLUMNS FROM " . $table) but without any success


Solution

  • What you are using is not Eloquent, but raw database queries.

    RAW queries:

    $table = 'your_table';
    $columns = DB::select("SHOW COLUMNS FROM ". $table);