Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
105 views
in Technique[技术] by (71.8m points)

php - Class 'appModelsJob' not found why ? What to do?

I have this command line that doesn't work but I tried namespace appModelsJob; or use appModelsJob; or namespace AppModelsJob; or use AppModelsJob;.

I have also tried directly adding AppModelsJob to the command line but it didn't seem to work.

namespace AppHttpControllers;

use appModelsJob;
use IlluminateHttpRequest;

class JobController extends Controller
{
    public function __construct(){
        $this->middleware(['employer','verified'],['except'=>array('index','show','apply','allJobs','searchJobs','category')]);
    }
    
    public function index(){
        $jobs = Job::latest()->limit(5)->where('status',1)->get();
        $categories = Category::with('jobs')->paginate(5);
        
        $companies = Company::get()->random(6);
       
        return view('welcome',compact('jobs','

Picture 1

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

class Job extends Model
{
    use HasFactory;

    protected $fillable = ['user_id','company_id','title','slug','description','roles','category_id','position','address','type','status','last_date','number_of_vacancy','experience','gender','salary'];
    
    public function getRouteKeyName(){
        return 'slug';
    }
    public function company(){
        return $this->belongsTo('AppCompany');
    }

    public function users(){
        return $this->belongsToMany(User::class)->withTimeStamps();
    }

    public function checkApplication(){
        return DB::table('job_user')->where('user_id',auth()->user()->id)->where('job_id',$this->id)->exists();
    }

    public function favorites(){
        return $this->belongsToMany(Job::class,'favourites','job_id','user_id')->withTimeStamps();
    }

    public function checkSaved(){
        return DB::table('favourites')->where('user_id',auth()->user()->id)->where('job_id',$this->id)->exists();
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should do this instead:

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsJob; // change app to App
class JobController extends Controller
{...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...