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',
];
}