2017-04-02 8 views
1

현재 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를 호출했습니다.

+0

클래스 \ App \ navire : 'Class'App \ Http \ Controllers \ navire '를 사용하지 않고 –

+0

@LeaTano를 호출 할 때 \'클래스 'App \ Eloquent'가 아닌 클래스를 \ 제거하십시오. ' –

+0

class navire extends \ Eloquent가 문제를 해결했습니다. thx :) –

답변

1

$navire = \App\navire::where('user_id',$user->id)->get()->take(1); 을 사용하거나 이미 모델을 가져 왔으므로 $navire = navire::where('user_id',$user->id)->get()->take(1); 즉 앞에 슬래시를 사용하지 마십시오.

또 다른 것은 ->get()->take(1) 대신 first()을 사용할 수 있습니다. 이와 같이 $navire = \App\navire::where('user_id',$user->id)->first();

+0

직접 navire를 사용하여 : : '클래스'App \ navire 'not found'오류 메시지가 표시됩니다. –

+0

@NicoAD App \ navire를 사용 했습니까? –

+0

이제 'Class'Authenticatable 'not found'메시지가 나타납니다. 문제가 해결 될 때마다 새로운 것을 얻습니다. 필자가 laravel 4에서 가장 좋아하는 것이 자동로드를위한 깨끗하고 우아한 솔루션이라는 것을 기억합니다. 5.4와 함께 이제 엉망이야 .. –