找不到类应用程序(Laravel 5.4)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42293927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:20:44  来源:igfitidea点击:

Class App Not Found (Laravel 5.4)

phplaravel

提问by EatCodePlaySleep

I've got a weird error. I want to just insert the remark fieldinto the database but it seems that it doesn't work. Please help.

我有一个奇怪的错误。我只想将备注字段插入数据库,但似乎不起作用。请帮忙。

Error says: Class 'App\Job' not found

错误说:找不到“App\Job”类

Jobs.php

工作.php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Job extends Model
{
    public function index()
    {
        return view('create-job');
    }

    public function user()
    {
        return  $this->belongsTo('App\User');
    }
}

JobController.php

作业控制器.php

namespace App\Http\Controllers;

use App\Job;
use Illuminate\Http\Request;


class JobController extends Controller
{
    public function postCreateJob(Request $request)
    {
        //Validation
        $post = new Job();
        $post->remarks = $request['remarks'];
        $request->job()->save($post);
        return redirect()->route('home');
    }

    public function index()
    {
        return view('create-job');
    }
}

回答by John

Your model name is Jobs.

你的模特名字是乔布斯。

Need to change the name of the model to Job

需要将模型名称更改为 Job

Hope this helps.

希望这可以帮助。