mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat wiki/ayuda section
This commit is contained in:
@ -3,6 +3,7 @@ namespace App\Entities\Wiki;
|
||||
|
||||
use App\Models\Wiki\WikiContentModel;
|
||||
use App\Models\Wiki\WikiPageModel;
|
||||
use App\Models\Wiki\WikiSectionRoleModel;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class WikiSectionEntity extends Entity
|
||||
@ -11,6 +12,7 @@ class WikiSectionEntity extends Entity
|
||||
"name" => null,
|
||||
"slug" => null,
|
||||
"role" => null,
|
||||
"order" => null,
|
||||
"icon" => null,
|
||||
"parent_id" => null
|
||||
];
|
||||
@ -19,6 +21,7 @@ class WikiSectionEntity extends Entity
|
||||
"slug" => "string",
|
||||
"role" => "string",
|
||||
"icon" => "string",
|
||||
"order" => "int",
|
||||
"parent_id" => "int"
|
||||
];
|
||||
|
||||
@ -34,10 +37,25 @@ class WikiSectionEntity extends Entity
|
||||
$this->attributes['contents'] = $this->content($locale);
|
||||
return $this;
|
||||
}
|
||||
public function withRoles(): self
|
||||
{
|
||||
$m = model(WikiSectionRoleModel::class);
|
||||
$this->attributes['roles'] = $this->roles();
|
||||
return $this;
|
||||
}
|
||||
public function withRolesArray(): self
|
||||
{
|
||||
$m = model(WikiSectionRoleModel::class);
|
||||
$this->attributes['roles_array'] = $this->roles_array();
|
||||
return $this;
|
||||
}
|
||||
public function withAll(string $locale = "es") : self
|
||||
{
|
||||
$this->withPage();
|
||||
$this->withContents($locale);
|
||||
$this->withRoles();
|
||||
$this->withRolesArray();
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
@ -46,6 +64,19 @@ class WikiSectionEntity extends Entity
|
||||
$m = model(WikiPageModel::class);
|
||||
return $m->where('section_id',$this->attributes['id'])->first();
|
||||
}
|
||||
public function roles_array(): ?array
|
||||
{
|
||||
$m = model(WikiSectionRoleModel::class);
|
||||
$section_roles = $m->where('wiki_section_id',$this->attributes['id'])->findAll();
|
||||
$roles = array_map(fn($r) => $r->role,$section_roles);
|
||||
return $roles;
|
||||
}
|
||||
public function roles(): ?array
|
||||
{
|
||||
$m = model(WikiSectionRoleModel::class);
|
||||
$section_roles = $m->where('wiki_section_id',$this->attributes['id'])->findAll();
|
||||
return $section_roles;
|
||||
}
|
||||
public function content(string $locale = "es"): ?WikiContentEntity
|
||||
{
|
||||
$page = $this->page();
|
||||
|
||||
Reference in New Issue
Block a user