Answers for "laravel eloquent get table columns names"

SQL
1

get table column names sql laravel

use IlluminateSupportFacadesSchema;

use IlluminateSupportFacadesDB;

public function getTableColumns($table)
{
    return DB::getSchemaBuilder()->getColumnListing($table);

    // OR

    return Schema::getColumnListing($table);

}
Posted by: Guest on December-05-2020
1

laravel eloquent get column

//return array of json
Model::where('id', 1)->get(['column1','column2']);
or
Model::all(['column1']);
//return array
Model::whereNull('deleted_at')->pluck('column1');
Posted by: Guest on March-23-2021

Code answers related to "laravel eloquent get table columns names"

Code answers related to "SQL"

Browse Popular Code Answers by Language