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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化