Search code examples
laravellaravel-5.3

Update error in Laravel: Class 'App\Http\Controllers\App\Category' not found


I am new to laravel and I am trying to update my table using the following code. But receiving the following error

Class 'App\Http\Controllers\App\Category' not found

My Code is

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use App\Category;
class CategoryController extends Controller
{


    public function UpdateCategory()
    {
        $category = App\Category::find(3);

        $category->name = 'Women';

        $category->save();
    }
}

Solution

  • use App\Category;
    

    you already include your model in controller. So you dont need to include once again

    $category = Category::find(3);
    

    simply use this