File: /home/imensosw/www/mpl.imenso.co/app/Pages/GenericPage.php
<?php
namespace App\Pages;
use Illuminate\Support\Str;
abstract class GenericPage
{
public function getSection() : string
{
return $this->section;
}
public function getSubSection() : string
{
return $this->subsection;
}
public function getName() : string
{
return $this->name;
}
public function getViewPath() : string
{
if (! $this->getSection()) {
return '';
}
if (! $this->getSubSection()) {
return $this->getSection().'.pages';
}
return $this->getSection().'.pages.'.$this->getSubSection();
}
public function getViewName() : string
{
if (! $this->getName()) {
return 'page';
}
if (! view()->exists($this->getViewPath().'.'.Str::kebab($this->getName()))) {
return 'page';
}
return Str::kebab($this->getName());
}
public function getView() : string
{
return $this->getViewPath().'.'.$this->getViewName();
}
// public static function isVisibleTo($user = false) : bool
// {
// if (is_object($user) && get_class($user) == User::class) {
// if ($this->getSection() && $this->getName()) {
// return config('pages.'.$this->getSection().'.'.kebab_case($this->getName()).'.visible-to.'.strtolower($user->type->getName()));
// }
// } else {
// if ($this->getSection() && $this->getName()) {
// return config('pages.'.$this->getSection().'.'.kebab_case($this->getName()).'.visible-to.guest');
// }
// }
// return false;
// }
}