A.Desert
A.Desert

Reputation: 41

Laravel - Request error on server

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.

Upvotes: 1

Views: 108

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163898

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.

Upvotes: 1

Related Questions