Specific error :
Class '\App\User::class' not found (View: C:\xampp\htdocs\contrex\resources\views\login.blade.php
)
I know this problem has been posted many times but i really can't find the solution.
I tried to create a directory "Models" so i can have all my models there. Before doing that it was working just fine so i tried to change the settings back to where it was - but now it doesn't work.
My User.php
<?php
namespace App;
namespace Illuminate\Foundation\Auth;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Notifications\Notifiable;
class User extends Model implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'facebook_id',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'remember_token',
];
}
My UserController.php
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function index(){
echo 'index';
}
public function create(){
echo 'create';
}
public function store(Request $request){
echo 'store';
}
public function show(){
}
public function edit($id){
echo 'edit';
}
public function update(Request $request, $id){
echo 'update';
}
public function destroy($id){
echo 'destroy';
}
}
My SocialAuthController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Illuminate\Support\Facades\Auth;
use Laravel\Socialite\Facades\Socialite;
class SocialAuthController extends Controller
{
public function redirect()
{
return Socialite::driver('facebook')->with(['auth_type' => 'rerequest'])->redirect();
}
public function callback()
{
try {
$user = Socialite::driver('facebook')->user();
} catch (Exception $e) {
return redirect('auth/facebook');
}
if($user->email == null)
return Socialite::driver('facebook')->with(['auth_type' => 'rerequest'])->redirect();
$authUser = $this->findOrCreateUser($user);
Auth::login($authUser, true);
return redirect()->route('login');
}
private function findOrCreateUser($facebookUser)
{
$authUser = User::where('facebook_id', $facebookUser->id)->first();
if ($authUser){
return $authUser;
}
return User::create([
'name' => $facebookUser->name,
'email' => $facebookUser->email,
'facebook_id' => $facebookUser->id,
]);
}
}
Settings on auth.php
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => 'App\User::class',
],
Settings on composer.json
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
I tried different things - also running php artisan config:clear
etc.
Any ideas?
via Antonis Tsimourtos