在Laravel中找不到模型

时间:2015-02-24 05:39:37

标签: php laravel

错误:PhotoController.php第17行中的FatalErrorException:未找到类'App \ Http \ Controllers \ photo'

此代码出现

异常 - > $ a = photo :: all();

**PhotoController ** 

   <?php namespace App\Http\Controllers;

    use App\Http\Requests;
    use App\Http\Controllers\Controller;
    use Illuminate\Http\Request;
    class PhotoController extends Controller { 
    public function index()
    {
        $a = photo::all();
        print_r($a); 
    }


    **// Photo  model** 

    <?php namespace App;
    use Illuminate\Database\Eloquent\Model;
    class Photo extends Model { 
        protected $table = 'users';  
    }

1 个答案:

答案 0 :(得分:3)

替换控制器

namespace App\Http\Controllers;
use App\models\Photo;

替换模型

namespace App\models;
use Illuminate\Database\Eloquent\Model;