PostController.php第12行中的FatalErrorException:找不到类'App \ Post'

时间:2016-12-01 10:07:10

标签: laravel hosting web-hosting

当我尝试使用此链接登录系统时出现此错误我正在使用此用户名:haa@gmail.com和此密码:haa1234。服务器或托管服务器可能存在什么问题,因为在本地计算机上工作正常。

app\Http\Controllers\PostController.php

这段代码是正确的。 这是系统的链接:

http://entrepreneurbase.haoyetu.com

,登录名为:

username: haa@gmail.com

password: haa1234

尝试这些凭据,您将收到我所描述的错误。

<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
//namespace routes;
use App\Post; 
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class PostController extends Controller
{
    public function getDashboard()
    {
        $posts = Post::orderBy('created_at','desc')->get();
        return view('dashboard', ['posts'=>$posts]);
    }
    public function postCreatePost(Request $request)
    {
        // Validation
        $this->validate($request, [
            'body' => 'required|max:1000'
            ]);
        $post = new Post();
        $post->body = $request['body'];
        $message = 'There was an error posting try again';
        if ($request->user()->posts()->save($post)) { 
            $message = 'post successfully created!';
        }
        return redirect()->route('dashboard')->with(['message' => $message]);
    }

    public function getDeletePost($post_id)
    {
        $post = Post::where('id', $post_id)->first();
        if (Auth::user() !=$post->user) {
            return redirect()->back();
        }
        $post->delete();
        return redirect()->route('dashboard')->with(['message' => 'successfully deleted!']);
    }

}

0 个答案:

没有答案