You’re resolving in the wrong way the models namespaces. Please have a look at the official PHP documentation
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
To be right you should have added a \
before App\Tag
, so PHP will resolve the class from the root. In this case, the use
statement will be useless
2
solved Class ‘App\Http\Controllers\App\Model’ not found