4

My auth.php file


'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => \App\Models\User::class, ], 

Usercontroller file:

<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\User; class UserController extends Controller { public function index() { $user = new User(); $user->name='SYED'; $user->email='[email protected]'; $user->password='ssass'; $user->save(); return view('home'); } } 

Everything is good to go but I dont know whats up with this code help! i have tried using everything but it does not solve please let me know if I'm doing some mistakes

3 Answers 3

7

You've used use App\User; in Usercontroller file:

change it as below.

use App\Models\User; 

As you're using the namespace of User model is App\Models so you need to use as use App\Models\User;

Sign up to request clarification or add additional context in comments.

Comments

4

Just use this in your controller

use use App\Models\User; instead of use App\User;

use App\Models\User; 

2 Comments

please mark as verified this answer if its help to you.. thank you @Ali Mohsin
why would they accept your answer instead of the answer from 10 minutes before yours that says the same thing? why the duplicate answer in the first place?
0

I got the answer very well: 1st:your model Class name must be as follow: class User extends Authenticatable 2nd:on your controller: use App\Models\User;

This work for sure.

2 Comments

the answer is fine, but try to provide a simple example
As subhadip said. This might answer the question, but rather than giving small "first this and then this" illustrate your answer by for example showing code chunks where it should be applied. As it is now, this is better suited as a comment to the question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.