So I deleted the Posts data type as I have a project coming up and I would like to use Voyager but the project does not include Posts. So after deleting the Posts data type, now my dashboard page does not load. Looks like the reason is the index.blade view still has the call for voyager posts. But I guess after deleting the Posts Data Type I would assume all Posts would be deleted from the system ???
So in order for me to get the admin dashboard back I had to go into the config/voyager.php file where all the configs are located and comment out the Post Widgets portion as such: lines 106 -112
'widgets' => [
[
'name' => 'User',
'icon' => 'voyager-group',
'model' => TCG\Voyager\Models\User::class,
'url' => 'admin/users',
'image' => '/images/widget-backgrounds/02.png',
],
// [
// 'name' => 'Post',
// 'icon' => 'voyager-news',
// 'model' => TCG\Voyager\Models\Post::class,
// 'url' => 'admin/posts',
// 'image' => '/images/widget-backgrounds/03.png',
// ],
[
'name' => 'Page',
'icon' => 'voyager-file-text',
'model' => TCG\Voyager\Models\Page::class,
'url' => 'admin/pages',
'image' => '/images/widget-backgrounds/04.png',
],
],
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'voyager.posts' doesn't exist (SQL: select count(*) as aggregate from posts) (View: C:\MAMP\htdocs\voyager\vendor\tcg\voyager\resources\views\index.blade.php)
in Connection.php line 770
go to Menu builder and delete the Posts from admin menu. go to database tools and delete the Post Bread, then delete the Post table. try to go to main admin page and get error. the reason is the index.blade.php grabs the voyager widgets config information from the config/voyager.php files config array. since I have deleted the Post table, the error is thrown.
Well, seems like your configuration is not being read. Can you try open up artisan tinker and let us know the output of the following code:
config('voyager.widgets');
here you go, Currently, I have the Posts data commented out in order to get he admin page to show but for this task I went ahead and uncommented it back to normal. ran the command in tinker, see results below:
again, it is reading config for widgets correctly, the problem is there is NO POST table anymore. So on the foreach, in the view file when it tries to get Post stuff it breaks, I comment out the Post in the config array and it works fine.
config('voyager.widgets');
=> [
[
"name" => "User",
"icon" => "voyager-group",
"model" => "TCG\Voyager\Models\User",
"url" => "admin/users",
"image" => "/images/widget-backgrounds/02.png",
],
[
"name" => "Post",
"icon" => "voyager-news",
"model" => "TCG\Voyager\Models\Post",
"url" => "admin/posts",
"image" => "/images/widget-backgrounds/03.png",
],
[
"name" => "Page",
"icon" => "voyager-file-text",
"model" => "TCG\Voyager\Models\Page",
"url" => "admin/pages",
"image" => "/images/widget-backgrounds/04.png",
],
]
That is no error. It is meant to be this way.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Most helpful comment
That is no error. It is meant to be this way.