4

I'm new to laravel

I have post table, this table has 10 columns.

So i want to get all column names in model Laravel Does this feature already work??

Or do I have to make it myself ??

Any suggestion or advice would be appreciated.

Thank you in advance

1

2 Answers 2

6

You can use the getColumnListing() method:

use Schema;
Schema::getColumnListing($this->getTable())
Sign up to request clarification or add additional context in comments.

Comments

2
$columns = Schema::getColumnListing('posts');
dd($columns);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.