Skip to content

Commit d9bef93

Browse files
authored
Update DbView.php
Updates my previous pull request that checked Laravel version. It was failing because it was finding '5.2' string in the 5.5.2 Laravel version. This new PR makes use of PHP's built in version_compare function to compare versions rather than just doing a string compare. Anything L5.4 and up uses flushStateIfDoneRendering().
1 parent 5d6e198 commit d9bef93

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Flynsarmy/DbBladeCompiler/DbView.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ public function render(Closure $callback = null)
7474
// Once we have the contents of the view, we will flush the sections if we are
7575
// done rendering all views so that there is nothing left hanging over when
7676
// anothoer view is rendered in the future by the application developers.
77-
( str_contains( app()->version(), ['5.3','5.2', '5.1']) ? View::flushSectionsIfDoneRendering() : View::flushStateIfDoneRendering());
77+
// Before flushing, check Laravel version for correct method use
78+
if ( version_compare(app()->version(), '5.4.0') >= 0 )
79+
View::flushStateIfDoneRendering();
80+
else
81+
View::flushSectionsIfDoneRendering();
7882

7983
return $response ?: $contents;
8084
}

0 commit comments

Comments
 (0)