Error Class App Http Controllers App Model not found

0 votes

Here is the Tag model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{
    protected $fillable = ['page_list_id', 'page_list_tag_id'];

    protected $with = ['tag'];

    public function tag()
    {
        return $this->belongsTo('App\PageListTag', 'page_list_tag_id', 'id');
    }
}

When I run my app I am getting the following error

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

What am I doing wrong in my code?

Apr 3, 2020 in Laravel by kartik
• 37,520 points
17,548 views

2 answers to this question.

0 votes

Hello,

In your code you're resolving the Tag class as follows

use App\Tag; // <-- This is right

But in your method you're calling

$pages->tags()->saveMany([
    new App\Tag(), // <-- And this is wrong!
    new App\Tag(),
]);

You simply have to call new Tag() since the use at the top of your file has already included the class.

Otherwise PHP will try to resolve the class from the current namespace. That's why it's throwing

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

Hope this work!!

Thank YoU!

answered Apr 3, 2020 by Niroj
• 82,880 points
0 votes

Class ‘App\Http\Controllers\Auth’ Not Found

in Class ‘App\Http\Controllers\Auth’ not found Resolve Error for Go to YourCustomController after that add use Auth; at the top on the Controller Page.


Solution For “Class ‘App\Http\Controllers\Auth’ Not Found”

use Auth; 
// Illuminate\Support\Facades\Auth

//or try it

use Illuminate\Support\Facades\Auth;
The solution posted by github user aliwesome seemed to be that you must use Auth Facade in Admin\Auth\LoginController

add this line :use Illuminate\Support\Facades\Auth;

This issue was posted on the github repo you reference. 

answered Aug 6, 2020 by pakainfo

Does this trick works for you??

Related Questions In Laravel

+1 vote
1 answer

Error:Class '\App\User' not found in Laravel when changing the namespace in Laravel?

Hello @kartik Go to config/auth.php and change App\User:class ...READ MORE

answered Apr 3, 2020 in Laravel by Niroj
• 82,880 points
30,103 views
0 votes
1 answer

Error: Class 'TestCase' not found in D:\xampp\htdocs\laravel\app\tests\ExampleTest.php on line 3 ,

Hello @kartik, Run following command in your project's ...READ MORE

answered Sep 28, 2020 in Laravel by Niroj
• 82,880 points
2,239 views
0 votes
1 answer

Artisan migration error “Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found”?

Hello @kartik, This message shows up if you ...READ MORE

answered Apr 6, 2020 in Laravel by Niroj
• 82,880 points
5,719 views
0 votes
1 answer

Error: Class 'SoapClient' not found in /home/user/mysite.com/path/to/file.php on line 16

Hello @kartik, find this line in php.ini : ;extension=soap then ...READ MORE

answered Oct 29, 2020 in Laravel by Niroj
• 82,880 points
3,362 views
0 votes
1 answer

Why it is necessary to refresh CSRF token per form request?

Hello, Generating a new CSRF token for each ...READ MORE

answered Mar 19, 2020 in Laravel by Niroj
• 82,880 points
4,517 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,239 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
1,268 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,328 views
0 votes
1 answer

Error:Class 'App\Http\Controllers\Model' not found

Hello @kartik, You need to import your model ...READ MORE

answered Sep 11, 2020 in Laravel by Niroj
• 82,880 points
5,207 views
0 votes
1 answer

Fatal error: Class 'App\Http\Controllers\Redirect' not found

Hello @kartik, The only thing that you have ...READ MORE

answered Oct 21, 2020 in Laravel by Niroj
• 82,880 points
6,237 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP