Blog-plugin: Call to undefined function RainLab\Blog\Models\optional()

Created on 16 Feb 2020  路  5Comments  路  Source: rainlab/blog-plugin

Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined function RainLab\Blog\Models\optional() in C:\OSPanel535\domains\october.local\plugins\rainlab\blog\models\Category.php:67

public function getPostCountAttribute() { return optional($this->posts_count->first())->count ?? 0; }

Question

Most helpful comment

october/backend v1.0.419
october/cms v1.0.419
october/rain v1.0.419
october/system v1.0.419
laravel/framework v5.1.46
Version problems. Thanks for pointing.

All 5 comments

@HugoBossOD Which PHP version are you running? Also, have you installed all of October CMS's dependencies?

CMS installed with composer.
Plugin installed with backend.
PHP 7.1.32
All needed PHP extensions enabled

Problem appears when accessing Blog Categories page in backend.

Tried to search code for 'optional('. Only mentioned in 'faker' files.
Now changed string to public function getPostCountAttribute() { return $this->posts_count->first()->count ?? 0; } and all seems working fine.

@HugoBossOD which version of October are you running?

The optional method is one provided by Laravel, however, it was not in Laravel 5.1 which October was based on before build 420.

october/backend v1.0.419
october/cms v1.0.419
october/rain v1.0.419
october/system v1.0.419
laravel/framework v5.1.46
Version problems. Thanks for pointing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rodrigogoncalves picture rodrigogoncalves  路  9Comments

rickmills picture rickmills  路  5Comments

Calinou picture Calinou  路  4Comments

marcomessa picture marcomessa  路  7Comments

AugmentBLU picture AugmentBLU  路  3Comments