File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 395395 */
396396 'with_property_constants ' => false ,
397397
398+ /*
399+ |--------------------------------------------------------------------------
400+ | Optionally includes a full list of columns in the base generated models,
401+ | which can be used to avoid making calls like
402+ |
403+ | ...
404+ | \Illuminate\Support\Facades\Schema::getColumnListing
405+ | ...
406+ |
407+ | which can be slow, especially for large tables.
408+ */
409+ 'with_column_list ' => false ,
410+
398411 /*
399412 |--------------------------------------------------------------------------
400413 | Disable Pluralization Name
Original file line number Diff line number Diff line change @@ -455,6 +455,13 @@ protected function body(Model $model)
455455 $ body .= $ this ->class ->field ('snakeAttributes ' , false , ['visibility ' => 'public static ' ]);
456456 }
457457
458+ if ($ model ->usesColumnList ()) {
459+ $ properties = array_keys ($ model ->getProperties ());
460+
461+ $ body .= "\n" ;
462+ $ body .= $ this ->class ->field ('columns ' , $ properties );
463+ }
464+
458465 if ($ model ->hasCasts ()) {
459466 $ body .= $ this ->class ->field ('casts ' , $ model ->getCasts (), ['before ' => "\n" ]);
460467 }
Original file line number Diff line number Diff line change @@ -1210,6 +1210,11 @@ public function usesPropertyConstants()
12101210 return $ this ->config ('with_property_constants ' , false );
12111211 }
12121212
1213+ public function usesColumnList ()
1214+ {
1215+ return $ this ->config ('with_column_list ' , false );
1216+ }
1217+
12131218 /**
12141219 * @return int
12151220 */
You can’t perform that action at this time.
0 commit comments