0

i am trying to create a notes(with title and body) that should be store in database for that i write some api (only valid user can able to create notes based on the token),i am able to get the token when successfully logged in , When i try to create a note it's throwing some error ,How to rectify that error please help me to fix this issue...

Error

Symfony\Component\Debug\Exception\FatalThrowableError Class 'Notes' not found in file /home/payarc/Desktop/newLaravel/app/Http/Controllers/NotesController.php on line 20

NotesController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Notes;
use App\Http\Controllers\Controller;


class NotesController extends Controller
{
    public function create_Note(Request $request)
    {
        $note=new Notes();
        
        $note->title=$request->input('title');
        $note->body=$request->input('body'); 
        $note->user_id = Auth()->id();         
        $note->save();
        return $note;
    }
}

2 Answers 2

2

Try to replace

use Notes;

with full path

use App\Models\Notes;
Sign up to request clarification or add additional context in comments.

Comments

-1

You simply use for creating object of notes model like this

$note=new AppNotes();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.