web.php第86行中的FatalThrowableError:在Laravel 5.4中找不到类'app \ Post'

时间:2017-05-09 18:17:54

标签: php routes laravel-5.4

我尝试用laravel运行我的页面(http://homestead.app/read),但在web.php第86行打印出这个“FatalThrowableError”: 类'app \ Post'未找到“错误消息。

我使用laravel 5.4

我的app / Post.php

<?php
namespace routes; 

use Illuminate\Database\Eloquent\Model; 
use Illuminate\Database\Eloquent\SoftDeletes; 

class Post extends Model 
{ 

use SoftDeletes; 


protected $dates = ['deleted_at']; 

protected $filleable = [ 
    'title',         
    'content' 

]; 

    public function user(){ 

    return $this->belongsTo('App\User'); 

    } 


}

我的app / Http / Controller / postController.php

<?php

namespace route\Http\Controllers;

use Illuminate\Http\Request;
use app\Post;

class PostsController extends Controller
{...}

和我的app / Post.php

<?php

use app\Post;

Route::get('/', function () {
return view('welcome');
});

Route::get('/read', function(){

    $posts = Post::all();

    foreach($posts as $post) {
            return $post->title;
    }

  });

0 个答案:

没有答案