Skip to content

Commit

Permalink
Adjust how the generic manage sections trait works
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Sep 12, 2021
1 parent 757de51 commit 6efcf59
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Generic/ManagesLayoutSections.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
*
* @package MallardDuck\LaravelTraits\Generic
*
* @property Factory|ManagesLayouts $viewFactory
* @property null|Factory&ManagesLayouts $viewFactory
*/
trait ManagesLayoutSections
{
/**
* @return Factory&ManagesLayouts
*/
public function getViewFactory(): Factory
{
return $this->viewFactory ?? app('view');
}

/**
* @param array $original
* @param array $current
Expand All @@ -31,13 +39,13 @@ private function sectionDataDiffers(array $original, array $current, string $sec

private function pushSectionData($name, $section)
{
$this->viewFactory->startSection($name, $section);
$this->getViewFactory()->startSection($name, $section);
}

private function overwriteSectionData($name, $section)
{
$this->viewFactory->startSection($name, null);
$this->getViewFactory()->startSection($name, null);
echo $section;
$this->viewFactory->stopSection(true); // pass true to overwrite prior section content
$this->getViewFactory()->stopSection(true); // pass true to overwrite prior section content
}
}

0 comments on commit 6efcf59

Please sign in to comment.