1

I'm trying get a Laravel project on a server ; everything work fine on local, I sent all the files to the server, changed routes.php and .env so that everything could work ( database, query, routes... ).

I work behind a reverse proxy, but it's not a problem to get the routes to work.

I can log in, but I cannot access or execute whatever that uses the Database (except log in).

Example :

Controller :

public function show($id) {
   $compte = Compte::find($id);
   $suiviFormation = User_formation::join('formation', 'formation.id_formation', '=', 'user_formation.id_formation')
                                            ->join('type_formation', 'formation.id_type_formation', '=', 'type_formation.id_type_formation')
                                            ->where('id_compte', $id)
                                            ->where(function($query){
                                                $query->where('formation.id_organisme', 1)
                                                        ->orWhere('formation.id_organisme', Auth::user()->id_organisme);
                                            })
                                            ->where('valide', 1)
                                            ->orderBy('type_formation.nom',  'asc')
                                            ->orderBy('formation.nom',  'asc')
                                            ->orderBy('date_formation',  'desc')
                                            ->get();
        $formations = array();
        $types = array();

        foreach($suiviFormation as $suivi){
            $formations[] = Formation::find($suivi->id_formation);
        }

        foreach($formations as $formation){
            $types[$formation->id_type_formation] = $formation->type_formation->nom;
        }   


        $userPoste = User_Poste::where('id_compte', $id)
            ->where('date_fin', null)
            ->first();


        $formationsAvailable = Formation::select('formation.id_type_formation', 'formation.nom', 'formation_importance.importance')
                                            ->join('formation_importance', 'formation_importance.id_formation', '=', 'formation.id_formation')
                                            ->join('poste', 'poste.id_poste', '=', 'formation_importance.id_poste')
                                            ->where('formation_importance.id_poste', $userPoste->id_poste)
                                            ->where('importance', '!=', 1)
                                            ->orderBy('formation.nom', 'asc')
                                            ->groupBy('formation.id_formation')
                                            ->get();

        return view('formation/formation_show', ['compte' => $compte, 'types' => $types, 'suiviFormation' => $suiviFormation,
            'formations' => $formations, 'formationsAvailable' => $formationsAvailable]);
    }

The error :

QueryException in Connection.php line 624: SQLSTATE[42S02]: Base table or view not found: 
1146 Table 'greement.Formation' doesn't exist 
(SQL: select * from `Formation` where `Formation`.`id_formation` = 61 limit 1)

Every single error look like this one.


Knowing that a part of the connexion to the database is working, how can other pages don't work ?

.env :

APP_ENV=local
APP_DEBUG=true
APP_KEY= appkey
DB_HOST= database.host
DB_DATABASE=greement
DB_USERNAME=user
DB_PASSWORD=*******
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

EDIT : I don't have direct access to the server, I can only use FTP & phpMyAdmin for the database.

1 Answer 1

1

You don't have tables in DB on your server. You need to run migrations with php artisan migrate command which will create tables for you. Or you can restore DB data on a server from a DB dump file.

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

4 Comments

I don't have access to the server directly so I can't perform this. I'll try with restoring the DB (added in question). Thanks
Restore the DB date from a .sql file didn't solve the problem, I'm still having the same error. Plus, I do have tables in the DB, because I couldn't log into the website if I didn't.
You want to tell me you have Formation table but still getting exactly the same error? If not, check with phpMyAdmin if table name is exactly the same Laravel is trying to use.
On the local DB, I have formation, which works well. On the server DB, I did have the same table, I renamed it to Formation to try if it changed something. I do have know Table 'greement.User_qual_ops' doesn't exist as an error. I just realize while writting this comment the error has changed. I'm going to try to rename all the tables. I just wonder why it need this change on the server as it doesn't care on the local DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.