我目前正在使用laravel 4.1移植一箇舊站點到laravel 5.4。已經實施了很多細微的變化(錯誤日誌幫助),但我堅持以下模型用法:laravel 5.4雄辯的模型加載,從4.1項目移植
namespace App;
class navire extends Eloquent
{
protected $table = 'navire';
public function user()
{
return $this->belongsTo('user');
}
public function getId()
{
return $this->id;
}
}
餘米試圖從一個控制器調用它:
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
use App\navire;
class UserController extends Controller
{
public function somefunc()
{
// ....
$navire = \navire::where('user_id',$user->id)->get()->take(1);
}
}
試着用很多東西「使用...」,或在開頭\調用它,沒什麼迄今努力的錯誤
exemples:
local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'App\Http\Controllers\navire' not found' in /home/user/www/app/Http/Controllers/UserController.php:30
local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'App\Http\Controllers\navire' not found' in /home/user/www/app/Http/Controllers/UserController.php:30
local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'App\navire' not found' in /home/user/www/app/Http/Controllers/UserController.php:32
local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'navire' not found' in /home/user/www/app/Http/Controllers/UserController.php:32
我已經叫dumpautoload。
當你調用它的時候從類中刪除\\ –
@LeaTano沒有使用App \ navire:'Class'App \ Http \ Controllers \ navire'找不到,與'Class'App \ Eloquent'沒有找到' –
class navire extends \ Eloquent修復了這個問題。 thx :) –