Newer
Older

Yassine Doghri
committed

Yassine Doghri
committed
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Entities;
use App\Models\CategoryModel;

Yassine Doghri
committed
use CodeIgniter\Entity\Entity;
/**
* @property int $id
* @property int $parent_id
* @property Category|null $parent
* @property string $code
* @property string $apple_category
* @property string $google_category
*/
class Category extends Entity
{

Yassine Doghri
committed
protected ?Category $parent = null;

Yassine Doghri
committed
/**
* @var array<string, string>
*/
protected $casts = [
'id' => 'integer',
'parent_id' => '?integer',
'apple_category' => 'string',
'google_category' => 'string',
];
/**
* @noRector ReturnTypeDeclarationRector
*/
public function getParent(): ?self
if ($this->parent_id === null) {

Yassine Doghri
committed
return null;
}

Yassine Doghri
committed
return (new CategoryModel())->getCategoryById($this->parent_id);