File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 22
33namespace Encore \Admin \Traits ;
44
5+ use Encore \Admin \Grid \Model as GridModel ;
6+
57trait ShouldSnakeAttributes
68{
9+ /**
10+ * Indicates whether attributes are snake cased on arrays.
11+ *
12+ * @var bool
13+ */
14+ protected static $ snakeAttributes ;
15+
716 /**
817 * Indicates if model should snake attribute name.
918 *
1019 * @return bool
1120 */
1221 public function shouldSnakeAttributes ()
1322 {
14- $ class = get_class ($ this ->model );
23+ if (is_bool (static ::$ snakeAttributes )) {
24+ return static ::$ snakeAttributes ;
25+ }
26+
27+ $ model = ($ this ->model instanceof GridModel) ?
28+ $ this ->model ->eloquent () : $ this ->model ;
29+
30+ $ class = get_class ($ model );
1531
16- return $ class ::$ snakeAttributes ;
32+ return static :: $ snakeAttributes = $ class ::$ snakeAttributes ;
1733 }
18- }
34+ }
You can’t perform that action at this time.
0 commit comments