dtamho6404 2017-11-27 20:39
浏览 61
已采纳

Laravel:在主题类中找不到void.Referenced类中没有找到方法'get'

While I use Laravel 5.5

public function index()
    {
        $posts = Post::orderBy('created_at','desc')->get();
        return view('post/index',compact('posts'));
        // ['posts' => $posts]);
    }

I met a issue:Method 'get' not found in void.Referenced class is not found in subject class

@foreach($posts as $post)
                <div class="blog-post">
                    <h2 class="blog-post-title"><a href="/posts/{{$post->id}}" >{{$post->title}}</a></h2>
                    <p class="blog-post-meta">{{$post->created_at}} by<a href="/user/5">Kassandra Ankunding2</a></p>

                    <p>{{$post->content}}
                    <p class="blog-post-meta">赞 0  | 评论 0</p>
                </div>
                @endforeach

this is the Post class:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

// 表 => posts
class Post extends Model
{
    //
    /**
     * @param $string
     * @param $string1
     */
    public static function orderBy($string, $string1)

    {

    }

}

After I remove all the function in Post class,it says:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'pet_shop.posts' doesn't exist (SQL: select * from posts order by created_at desc)" Anybody can help?

  • 写回答

2条回答 默认 最新

  • doutuo1908 2017-11-28 01:10
    关注

    I feel a little sorry……

    I finally solved this issue by restart the server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 请求分析基于spring boot+vue的前后端分离的项目
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?