Closed Thiktak closed 1 year ago
@Thiktak Thank you for your contribution! I appreciate your effort and the time you've dedicated to improving the package
viewSidebar
property, public static bool $hasSidebar = true;
property to HasPageSidebar
$view
property of the page and $hasSidebar
of HasPageSidebar
trait for adding sidebar to the pagenamespace AymanAlhattami\FilamentPageWithSidebar\Traits;
trait HasPageSidebar
{
/**
* add sidebar to the page
*/
public static bool $hasSidebar = true;
/**
* public function mountHasPageSidebar
* Register automatically view if available
*/
public function bootHasPageSidebar(): void
{
// Why boot ? https://livewire.laravel.com/docs/lifecycle-hooks#boot
// Using ${'view'} instead of $view in order to avoid Intelephense warning
if (static::$hasSidebar) {
static::${'view'} = 'filament-page-with-sidebar::proxy';
}
}
/**
* public function getIncludedSidebarView
* Return string include view
*/
public function getIncludedSidebarView(): string
{
if (is_subclass_of($this, '\Filament\Pages\Page')) {
$props = collect(
(new \ReflectionClass($this))->getDefaultProperties()
);
if ($props->get('view')) {
return $props->get('view');
}
}
// Else:
throw new \Exception('No view detected for the Sidebar. Implement Filament\Pages\Page object with valid static $view');
}
}
Why these changes? one $view
property for the page view blade is better than having two properties $view
and $viewSidebar
Kudos, SonarCloud Quality Gate passed!
I edited it.
This should be cleaner now.
Thanks @Thiktak
A possible solution about the issue #16
Implement like this, without creating any view:
Tested with Infolist & Edit.
Feel free to improve.