column not find after run a "composer update"

Published 7 months ago by jahstation

I run gentelella admin template over laravel 5.4, after seeing that there is some bug that are fixed with the new relase of Gentelella I tried to run: composer update on my root project folder to fix issue, the command was ok with no error rised during exectution.

After i try to access to the home page of my project but ive received this error message:

(2/2) QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (SQL: select * from users where `` = 1 limit 1) in Connection.php (line 647)

where i wrong something? thanks thanks

BezhanSalleh

try

php artisan cache:clear
php artisan config:cache
 
//if you are not using closures in your web.php
php artisan route:cache
//if you are run this instead
php artisan route:clear
//and finally
php artisan view:clear
php artisan serve

if that didn't help, show us your controller code for home page and if you have authentication in place your AuthenticatesUsers trait.

jahstation

no this not solve my problems, and the controller are not modified from before/after composer update!

I read that can be a problem about primary key of the user and i try to add: protected $primaryKey = 'id';

on my user's model, but again this didnt fix my issue

BezhanSalleh

did you edit your composer.json file or something, cause unless you didn't change anything in your code or added a new package. composer update won't cause anything like this. not for me anyway... are you using the Laravel 5 Boilerplate ?

jahstation

ok maybe i made a wrong step runnings composer update. but i didnt think to broke all!

by the way no edit con composer.json file

BezhanSalleh

haha, no worries, the only way to learn! how did you update the template? unless we see some code, i don't know how to help...

jahstation

the only operation made from before (site working) and after (site broken) is to run "composer update" that was run without errors, and no edit over the composer.json. the template is still to update so!

so im with a broken site with a non update template that have a bug! :D whatta lovely day!

ive no idea about what i can show you to try to solve the probelm... the file that u mention are not edited!

jahstation

this is the composer update output:

composer update Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 27 updates, 0 removals

  • Updating tijsverkoyen/css-to-inline-styles (2.2.0 => 2.2.1) Loading from cache
  • Updating symfony/polyfill-mbstring (v1.5.0 => v1.6.0) Loading from cache
  • Updating symfony/var-dumper (v3.3.10 => v3.4.3) Loading from cache
  • Updating symfony/routing (v3.3.10 => v3.4.3) Loading from cache
  • Updating symfony/process (v3.3.10 => v3.4.3) Loading from cache
  • Installing symfony/polyfill-php70 (v1.6.0) Loading from cache
  • Updating symfony/http-foundation (v3.3.10 => v3.4.3) Loading from cache
  • Updating symfony/event-dispatcher (v3.3.10 => v3.4.3) Loading from cache
  • Updating symfony/debug (v3.3.10 => v3.4.3) Loading from cache
  • Updating symfony/http-kernel (v3.3.10 => v3.4.3) Loading from cache
  • Updating symfony/finder (v3.3.10 => v3.4.3) Loading from cache
  • Updating symfony/console (v3.3.10 => v3.4.3) Loading from cache
  • Updating ramsey/uuid (3.7.1 => 3.7.2) Loading from cache
  • Updating symfony/translation (v3.3.10 => v3.4.3) Loading from cache
  • Updating mtdowling/cron-expression (v1.2.0 => v1.2.1) Loading from cache
  • Updating erusev/parsedown (1.6.3 => 1.6.4) Loading from cache
  • Updating doctrine/inflector (v1.1.0 => v1.2.0) Loading from cache
  • Updating watson/bootstrap-form (1.1.11 => 1.1.14 Downloading: 100% .
  • Updating spatie/laravel-permission (1.13.0 => 1.15.0) Downloading: Connectin Downloading: 100%
  • Updating ixudra/curl (6.13.0 => 6.16.0) Downloading: 100%
  • Updating symfony/yaml (v3.3.10 => v3.4.3) Downloading: 100%
  • Updating phpunit/php-file-iterator (1.4.2 => 1.4.5) Loading from cache
  • Updating phpunit/php-token-stream (1.4.11 => 2.0.2) Loading from cache
  • Updating phpdocumentor/type-resolver (0.3.0 => 0.4.0) Loading from cache
  • Updating phpdocumentor/reflection-docblock (3.2.2 => 4.2.0) Loading from cache
  • Updating phpspec/prophecy (v1.7.2 => 1.7.3) Loading from cache
  • Updating myclabs/deep-copy (1.6.1 => 1.7.0) Loading from cache
  • Updating phpunit/phpunit (5.7.22 => 5.7.26) Downloading: 100% Writing lock file Generating autoload files

Illuminate\Foundation\ComposerScripts::postUpdate php artisan optimize Generating optimized class loader The compiled services file has been removed. [email protected]:~/workspace/vAss$ php artisan serve

BezhanSalleh

ok, after composer update you need to run

php artisan cache:clear
php artisan config:cache //if you updated or publish any new config via vendor:publish

Now: in your web.php add the follwing before your auth routes

Route::get('/getUsers', function(){
    return App\User::first();
    //or dd(App\User::first());
});

navigate to http://localhost:8000/getUsers see if it displays anything... if not the problem might be with the update of laravel-permission from 1.13.0 to 1.15.0 so edit your composer.json and set the version back to 1.13.0... and nothing helps, start again with your recent back up

jahstation

adding the complete path on the model so "App\Models\User" and then import it on web.php, it works!

BezhanSalleh

what works?

jahstation

your function show me the user!

trying to troubleshooting ive found that the code that rise the error is inside Class "Authenitcate" function "handle"

Auth::guard($guard)->guest()

BezhanSalleh

unless you are overriding the default Authenticate should be like this

class Authenticate
{
    /**
     * The authentication factory instance.
     *
     * @var \Illuminate\Contracts\Auth\Factory
     */
    protected $auth;

    /**
     * Create a new middleware instance.
     *
     * @param  \Illuminate\Contracts\Auth\Factory  $auth
     * @return void
     */
    public function __construct(Auth $auth)
    {
        $this->auth = $auth;
    }

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string[]  ...$guards
     * @return mixed
     *
     * @throws \Illuminate\Auth\AuthenticationException
     */
    public function handle($request, Closure $next, ...$guards)
    {
        $this->authenticate($guards);

        return $next($request);
    }

    /**
     * Determine if the user is logged in to any of the given guards.
     *
     * @param  array  $guards
     * @return void
     *
     * @throws \Illuminate\Auth\AuthenticationException
     */
    protected function authenticate(array $guards)
    {
        if (empty($guards)) {
            return $this->auth->authenticate();
        }

        foreach ($guards as $guard) {
            if ($this->auth->guard($guard)->check()) {
                return $this->auth->shouldUse($guard);
            }
        }

        throw new AuthenticationException('Unauthenticated.', $guards);
    }
}
jahstation

no... this is the code present even online -where the site still works- and i didnt touch anything in this class

public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->guest()) { if ($request->ajax() || $request->wantsJson()) { return response('Unauthorized.', 401); } else { return redirect()->guest('login'); } }

    return $next($request);
}
jahstation
jahstation

another cool feature for me: if i open the home from the "icognito mode" the framework show me the page but the login not works anymore

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