Grace
Grace

Reputation: 299

Laravel Get Column Name error

i'm trying to get all the column name in my database table but i always end up with this error,enter image description here

My Controller:

public function gettable()
{
    $points = new Point;
    $columns=$points->getTableColumns('points');


    dd($columns->all());
}

My Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Point extends Model
{
    protected $guarded = ['id', 'name']; 

    public function getTableColumns($table)
    {
        return Schema::getColumnListing($table);
    }

}

Can anyone point me to a proper solution thanks..

Upvotes: 0

Views: 334

Answers (1)

DsRaj
DsRaj

Reputation: 2328

There is a syntax error

you need to use single quote ' or double quote " instead of an apostrophe replace this line with From

protected $guarded = [‘id’, ‘name’];

To

protected $guarded = ['id', 'name'];

Upvotes: 1

Related Questions