Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

unexpected '!='

Hello,

I wonder why I get this error message:

Parse error: syntax error, unexpected '!=' (T_IS_NOT_EQUAL)

Basically if foto_ktp is not null then it should opens www.shopee.co.id .

LoginController.php

if(auth()->attempt(['username' => request('username'), 'password' => request('password')]))
    {   

        if(User::where('id', auth::id())->get('foto_ktp')) != NULL)
            {
            return redirect('http://www.shopee.co.id'); 
            }
        else 
            return redirect('/seller');                     
            
    }
0 likes
5 replies
Vilfago's avatar

You close the if with ) before the !=.

if(User::where('id', auth::id())->get('foto_ktp') != NULL)

But even like that, I'm not sure it will work, because a collection will be returned.

Try:

if(User::where('id', auth::id())->get('foto_ktp')->isNotEmpty())
{
return ...
davy_yg's avatar
Level 27

Type error: Argument 1 passed to Illuminate\Database\Grammar::columnize() must be of the type array, string given, called in C:\xampp\htdocs\shopee_lvl\framework\vendor\laravel\framework\src\Illuminate\Database\Query\Grammars\Grammar.php on line 131

LoginController.php

if(auth()->attempt(['username' => request('username'), 'password' => request('password')]))
    {   

        if(User::where('id', auth::id())->get('foto_ktp')->IsNotEmpty())
            {
            return redirect('http://www.shopee.co.id'); 
            }
        else 
            return redirect('/seller');                     
            
    }
davy_yg's avatar
Level 27
if(auth()->attempt(['username' => request('username'), 'password' => request('password')]))
        {   

        $value = User::where('id', auth::id())->get();

        dd($value);

Collection {#565 ▼ #items: array:1 [▼ 0 => User {#563 ▼ #primaryKey: "id" #guarded: array:1 [▶] #hidden: array:2 [▶] #connection: "mysql" #table: null #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: false #attributes: array:10 [▼ "id" => 4 "email" => "[email protected]" "username" => "mike_ok" "password" => "$2y$10$Dgvx6ODY12uznqOCfzBghOE5bHcnR0gfyI1Xe4/uHQMW88Affp9CG" "no_ktp" => "1234567812345678" "foto_ktp" => "KTP Davy2.jpg" "foto_profile" => "photo.jpg" "sign_up" => "" "updated_at" => "2018-04-22" "created_at" => "2018-04-21"

Why if I do this:

if(auth()->attempt(['username' => request('username'), 'password' => request('password')]))
        {   

        $value = User::where('id', auth::id())->get();

        dd($value->no_ktp);

Property [no_ktp] does not exist on this collection instance.

Note : the user table is from modifying the original user default table:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
use Notifiable;

/**
 * The attributes that are mass assignable.
 *
 * @var array
 */
protected $primaryKey = 'id';
protected $guarded = ['id'];

/**
 * The attributes that should be hidden for arrays.
 *
 * @var array
 */
protected $hidden = [
    'password', 'remember_token',
];
 }
rin4ik's avatar
rin4ik
Best Answer
Level 50

try this. I hope in users table u have foto_ktp field


if(auth()->attempt(['username' => request('username'), 'password' => request('password')]))
    {   

           if(!empty(Auth::user()->foto_ktp))
            {
               return redirect('http://www.shopee.co.id'); 
            }
        else 
            return redirect('/seller');                     
           }

Please or to participate in this conversation.