What's up guys
I have this issue facing now on my project as follows :
I call up my view_cell somewhere;
PHP Code:
<?= view_cell('\App\Libraries\Blog::recentPosts', 'slug=BlogModel, limit=5') ?>
and this is a Libraries for
and
PHP Code:
<?php namespace App\Libraries;
use Admin\Models\BlogModel;
class Blog{
public function recentPosts (string $slug, int $limit)
{
$model = new BlogModel();
$posts = $this->BlogModel->where('slug', $slug)
->orderBy('title', 'desc')
->limit($limit)
->get();
return view('\Admin\Views\Widgets\recentPosts', ['posts' => $posts]);
}
}
The last my widget to fetch data;
PHP Code:
</php Admin\Views\Widgets\recentPosts ?>
Then I get this exception
Why?
Undefined property: App\Libraries\Blog::$BlogModel search →
APPPATH\Libraries\Blog.php at line 10
Code:
APPPATH\Libraries\Blog.PHP at line 10
3 use Admin\Models\BlogModel;
4
5 class Blog{
6 public function recentPosts (string $slug, int $limit)
7 {
8 $model = new BlogModel();
9
10 $posts = $this->BlogModel->where('slug', $slug)
11 ->orderBy('title', 'desc')
12 ->limit($limit)
13 ->get();
14
15 return view('\Admin\Views\Widgets\recentPosts', ['posts' => $posts]);
16 }
17 }
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals