Reflectionexception Laravel 5.7 instance Gcloud

Asked

Viewed 63 times

0

I have deployed my application to a Gcloud instance and cannot access a specific page where I import files.

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use App\IdeoProduct;
use App\NextProduct;
use App\Estoque;
use Illuminate\Support\Facades\Storage;

class ImportController extends Controller
{
    public function index()
    {
        return view('import.indexImportador');
    }

    public function importEstoque(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'file' => 'required'
        ]);
        if ($validator->fails()) {
            return redirect()
                ->back()
                ->withErrors($validator);
        }
        $file = $request->file('file');
        $csvData = file_get_contents($file);
        $rows = array_map("str_getcsv", explode("\n", $csvData));
        $header = array_shift($rows);
        foreach ($rows as $row) {
            $row = array_combine($header, $row);
            Estoque::insert([
                'codigo' => $row['Código'],
                'nome' => $row['Produto'],
                'estoque' => $row['Qtd.'],
            ]);
        }

        return redirect()->route('importador');
    }

    public function importProdIdeo(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'file' => 'required'
        ]);
        if ($validator->fails()) {
            return redirect()
                ->back()
                ->withErrors($validator);
        }

        $file = $request->file('file');
        $csvData = file_get_contents($file);

        $rows = array_map("str_getcsv", explode("\n", $csvData));
        $header = array_shift($rows);
        foreach ($rows as $row) {
            $row = array_combine($header, $row);
            DB::table('ideo_products')->insert([
                'codigo' => $row['Código de Barra'],
                'nome' => $row['Produto'],
                'preco' => $row['Preço'],
            ]);
        }
        return redirect()->route('prodIdeo');

    }

    public function importProdNext(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'file' => 'required'
        ]);
        if ($validator->fails()) {
            return redirect()
                ->back()
                ->withErrors($validator);
        }
        $file = $request->file('file');
        $csvData = file_get_contents($file);
        $rows = array_map("str_getcsv", explode("\n", $csvData));
        $header = array_shift($rows);
        foreach ($rows as $row) {
            $row = array_combine($header, $row);
            NextProduct::create([
                'codigo' => $row['Código'],
                'nome' => $row['Nome'],
                'preco' => $row['Preço']
            ]);
        }
        return redirect()->route('prodNext');
    }

    public function importPrecoCusto(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'file' => 'required'
        ]);
        if ($validator->fails()) {
            return redirect()
                ->back()
                ->withErrors($validator);
        }
        $file = $request->file('file');
        $csvData = file_get_contents($file);
        $rows = array_map("str_getcsv", explode("\n", $csvData));
        $header = array_shift($rows);
        foreach ($rows as $row) {
            $row = array_combine($header, $row);
            DB::table('preco_custo')
                ->insert([
                    'codigo' => $row['Código'],
                    'nome' => $row['Produto'],
                    'precoCusto' => $row['Vl. Custo']
                ]);
        }
        return redirect()->route('precoCusto');
    }

    public function importClientes(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'file' => 'required'
        ]);
        if ($validator->fails()) {
            return redirect()
                ->back()
                ->withErrors($validator);
        }
        $file = $request->file('file');
        $csvData = file_get_contents($file);
        $rows = array_map("str_getcsv", explode("\n", $csvData));
        $header = array_shift($rows);
        foreach ($rows as $row) {
            $row = array_combine($header, $row);
            DB::table('clientes')
                ->insert([
                    'cnpj_cpf' => $row['Cnpj CPF'],
                    'nome' => $row['Nome'],
                    'rg_ie' => $row['Rg/Ie'],
                    'telefone_1' => $row['Tel1'],
                    'telefone_2' => $row['Tel2'],
                    'fax' => $row['Tel3'],
                    'email' => $row['Email'],
                    'longradouro' => $row['Longradouro'],
                    'numero' => $row['numero'],
                    'complemento' => $row['complemento'],
                    'bairro' => $row['bairro'],
                    'cidade' => $row['cidade'],
                    'uf' => $row['uf'],
                    'cep' => $row['cep']
                ]);
        }
        return redirect()->route('clientes');
    }
}

Error

(1/1) ReflectionException
Class App\Http\Controllers\importController does not exist

in Container.php line 779
at ReflectionClass->__construct('App\\Http\\Controllers\\importController')
in Container.php line 779
at Container->build('App\\Http\\Controllers\\importController')
in Container.php line 658
at Container->resolve('App\\Http\\Controllers\\importController', array())
in Container.php line 609
at Container->make('App\\Http\\Controllers\\importController', array())
in Application.php line 735
at Application->make('App\\Http\\Controllers\\importController')
in Route.php line 233
at Route->getController()
in Route.php line 833
at Route->controllerMiddleware()
in Route.php line 794
at Route->gatherMiddleware()
in Router.php line 695
at Router->gatherRouteMiddleware(object(Route))
in Router.php line 675
at Router->runRouteWithinStack(object(Route), object(Request))
in Router.php line 659
at Router->runRoute(object(Request), object(Route))
in Router.php line 625
at Router->dispatchToRoute(object(Request))
in Router.php line 614
at Router->dispatch(object(Request))
in Kernel.php line 176
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in TrustProxies.php line 57
at TrustProxies->handle(object(Request), object(Closure))
in Pipeline.php line 151
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in TransformsRequest.php line 31
at TransformsRequest->handle(object(Request), object(Closure))
in Pipeline.php line 151
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in TransformsRequest.php line 31
at TransformsRequest->handle(object(Request), object(Closure))
in Pipeline.php line 151
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure))
in Pipeline.php line 151
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in CheckForMaintenanceMode.php line 62
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
in Pipeline.php line 151
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in Pipeline.php line 104
at Pipeline->then(object(Closure))
in Kernel.php line 151
at Kernel->sendRequestThroughRouter(object(Request))
in Kernel.php line 116
at Kernel->handle(object(Request))
in index.php line 55
  • 1

    That is the mistake: Class App\Http\Controllers\importController does not exist. Somewhere you’re calling the ImportController with the letter i lowercase.

  • Guys, thanks for the help. My Routes was incorrect. I had a route I called importController (With tiny i).. When putting the capital I worked

  • The error is how you typed "importController" see that you have i instead of i (Importcontroller). If the server is on Linux, you should type exactly as the name is. Probably for you (Local) is working because you are using Windows. I believe the error is in your Routes file.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.