내 모든 api는 localhost에서 잘 작동합니다. 라이브 서버 (우분투 16.04) 내가이 오류가 프로젝트의 특정 세부 사항을 얻으려고 요청이 오류가 발생합니다. 나는 많은 클래스 모델을 (내가 사용 laravel elequonet techniq)이 특정 프로젝트를 취득하는 파일에서 모델 클래스를 찾을 수 없습니다. /var/www/html/projects/api/vendor.../src/Illuminate/Database/..HasRelationships.php on line 506
Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App\Rewards' not found in file /var/www/html/projectsfundingandsharing/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on line 506
Stack trace:
1. Symfony\Component\Debug\Exception\FatalThrowableError->() /var/www/html/projectsfundingandsharing/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php:506
이이 내 프로젝트의 모델 클래스 내 루트/api.php 파일
use Illuminate\Http\Request;
Use App\Article;
Use App\Projects;
Use App\User;
Use App\Rewards;
Use App\Comments;
Use App\User_address;
Use App\Shipping_location;
Use App\ProjectController;
Use App\rewardsController;
Use App\storyController;
Use App\CommentsController;
use App\ActivationService;
//everything works fine when i call this api.
Route::get('projects', '[email protected]');
//errors is occurring here when i trying get all relational models class.
Route::get('projects/{id}', function($id) {
$project = Projects::with('rewardsProject.shippings','projectImage', 'projectFaqs','projectStory','userdetails', 'user.user_address')
->where('id', $id)
->get();
return $project;
//return Projects::find($id)->user->user_address;
});
입니다
namespace App;
use App\Project_images;
use App\Comments;
use App\Rewards;
use Illuminate\Database\Eloquent\Model;
use Eloquent;
use Illuminate\Support\Facades\DB;
class Projects extends Model
{
protected $fillable = ['title', 'video_url', 'pledged_amount', 'currency', 'end_date', 'funded_amount', 'percent_funded', 'funding_model', 'start_date', 'duration', 'category_id', 'category_name', 'user_name','user_id', 'total_backers', 'picture', 'links'];
public function projectUser(){
return $this->hasOne('App\User');
}
public function projectStory(){
return $this->hasOne('App\Story');
}
public function projectFaqs(){
return $this->hasMany('App\Faqs');
}
public function projectRewd()
{
return $this->belongsToMany('App\Rewards','rewards', 'projects_id');
// return $this->hasMany('App\Rewards');
}
public function projectShip()
{
return $this->belongsToMany('App\Shipping_location', 'shipping_locations','reward_id','project_id');
//return $this->belongsToMany('App\Role', 'role_user', 'user_id', 'role_id');
}
public function projectImage()
{
return $this->hasMany('App\Project_images');
}
public function rewardsProject(){
return $this->hasMany('App\Rewards');
}
public function userdetails(){
return $this->hasOne('App\User','id', 'user_id');
}
public function user(){
return $this->belongsTo('App\User');
//return $this->hasManyThrough('App\User', 'App\User_address');
}
}
이 내 rewards.php 모델 클래스
namespace App;
use Illuminate\Database\Eloquent\Model;
class rewards extends Model
{
protected $fillable = ['amount', 'delivery_date', 'projects_id', 'quantity', 'backers_count', 'currency', 'contain_shipping_locations', 'title', 'description'];
/*----*/
public function projects() {
return $this->belongsTo('App\Projects');
}
public function shippings(){
return $this->belongsToMany('App\Shipping_location','rewards_shipping_location', 'reward_id', 'shipping_location_id');
}
}
마찬가지로 모든 올바른 모델 클래스를 넣습니다.
내가이하는 오류를 받고있는 이유에 저를 도와주세요, 내가 모든 클래스 파일에 App\Rewards
경로를 놓고, 내가 경로에 rewardsProject.shippings
을 제거 할 때/api.php 파일은 내가 App/Story not found
'composer dump-autoload'를 실행 했습니까? – Ben
예, 저도 해봤지만 작동하지 않았습니다. –