Monday, March 7, 2022

[FIXED] Class App not found error in (Laravel 5.4)

Issue

I want to insert the remark field into the database, but it seems that it doesn't work. So instead, I get the following error.

Class 'App\Job' not found

Jobs.php

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

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

JobController.php

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');
    }
}

Solution

Your model name is Jobs.

Need to change the name of the model to Job

Hope this helps.



Answered By - John

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.