【问题标题】:How to rectify Symfony\Component\Debug\Exception\FatalThrowableError error in laravel-6?如何纠正 laravel-6 中的 Symfony\Component\Debug\Exception\FatalThrowableError 错误?
【发布时间】:2021-09-03 06:45:26
【问题描述】:

我正在尝试创建一个应该存储在数据库中的注释(带有标题和正文),因为我编写了一些 api(只有有效的用户才能基于令牌创建注释),我能够获得令牌成功登录后,当我尝试创建便笺时,它会抛出一些错误,如何纠正该错误,请帮助我解决此问题...

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

【问题讨论】:

    标签: php laravel laravel-6


    【解决方案1】:

    尝试替换

    use Notes;
    

    有完整路径

    use App\Models\Notes;
    

    【讨论】:

      【解决方案2】:

      你只是用来创建这样的笔记模型对象

      $note=new AppNotes();
      

      【讨论】:

        猜你喜欢
        • 2019-08-02
        • 2020-05-15
        • 2018-08-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-21
        • 1970-01-01
        • 2017-12-06
        相关资源
        最近更新 更多