Reputation: 1631
I created a new class under /app/UserRepositories/UserRepository.php
.
Now i want to use it in my AuthenticateUser.php
under /app
.
I tried to import it like that use App\Repositories\UserRepository;
but I get still the same error: Class does not exist
UserRepository.php
<?php use App\Repositories;
use App\User;
class UserRepository {
public function updateOrCreate($userData)
{
return User::firstOrCreate([
'username' => $userData->username,
'email' => $userData->email,
'avatar' => $userData->avatar
]);
}
}
Upvotes: 0
Views: 91
Reputation: 6957
At the beginning of your file /app/UserRepositories/UserRepository.php
, you will need to namespace it using:
namespace App\UserRepositories;
Then you can import it to be used anywhere by:
use App\UserRepositories\UserRepository;
Upvotes: 1