Repositories

Published 1 month ago by omarsow94

I have Class App\Repositories\ConversationRepository does not exist error but in my controller i put : use App\Repositories\ConversationRepository; and in my Repositories\ConversationRepository i put namespace App\Repositories; . I think everythink is OK but this error message still

Best Answer (As Selected By omarsow94)
omarsow94

I work fine now , i don't know exactly why, i just replace ConversationRepository by ConversationsRepository ( add s to Conversation) .

bestmomo
bestmomo
1 month ago (374,890 XP)

Try a composer dumpautoload

omarsow94

Already done, but the message error still @bestmomo

bestmomo
bestmomo
1 month ago (374,890 XP)

Looks weird, check the typo, sometimes there is a hidden stuff...

omarsow94

I change

use App\Repositories\ConversationRepository;

to

use App\Repositories\test;

so normally i should have this message error

Class App\Http\Controllers\test does not exist

but not i have the same message

Class App\Http\Controllers\ConversationRepository does not exist
impbob
impbob
1 month ago (65,705 XP)

Some OSs are case sensitive too. Double check the filenames, and directories, have the same capitalized case.

Run the following to flush out data

composer dumpautoload
php artisan cache:clear
php artisan config:clear
omarsow94

I still have the same error after running the commands lines @impbob

Class App\Http\Controllers\ConversationRepository does not exist
jbloomstrom

Can you post the whole controller file?

omarsow94

the whole controller :

<?php

namespace App\Http\Controllers;

use App\Repositories\ConversationRepository;
use Illuminate\Http\Request;
use Illuminate\Auth\AuthManager;
use Illuminate\Support\Facades\Auth;
use App\User;


class ConversationsController extends Controller
{
    private $r;
    private $auth;

    public function __construct(ConversationRepository $conversationRepository, AuthManager $auth)
    {
        $this->r = $conversationRepository;
        $this->auth = $auth;
    }
    public function index()
    {
        return view('conversations.index',[
            'users' => $this->r->getConversations($this->auth->user()->id)
        ]);
    }

    public function show(User $user)
    {
        return view('conversations.show',[
            'users' => $this->r->getConversations($this->auth->user()->id),
            'user' => $user
        ]);
    }

    public function store(User $user, Request $request)
    {
        $this->r-createMessage(
            $request->get('content'),
            $request->auth->user()->id,
            $user->id
        );
    }


}

@jbloomstrom

jbloomstrom

The error could be coming from a different file. Can you post the snippet from your laravel log that contains the full error message?

omarsow94

@jbloomstrom the latest message in laravel.log file is :

[2018-01-18 01:07:18] local.ERROR: Class App\Http\Controllers\ConversationRepository does not exist {"exception":"[object] (ReflectionException(code: 0): Class App\Http\Controllers\ConversationRepository does not exist at /var/www/html/VueJS/chat/vendor/laravel/framework/src/Illuminate/Container/Container.php:811)
[stacktrace]
MaverickChan

conversations or conversation?

are they 2 different controller or just a mis-spelling error?

omarsow94

conversation @MaverickChan , i have ConversationsController with 's' and ConversationRepository without 's'

MaverickChan

@omarsow94 if you are using linux or mac , check file ownership when you copy it from elsewhere.

omarsow94

I use Linux , i should put 777 ? (chmod) @MaverickChan

MaverickChan

@omarsow94 try writing a new file , copy the content from the old .

Please sign in or create an account to participate in this conversation.