i'm trying to retrieve a column from my database with laravel.. i've confirmed the column actually exists but apparently laravel doesn't think the same.. any help? thanks!
The error is the following..
"Property [Salt] does not exist on this collection instance."
accounts model:
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class accounts extends Authenticatable
{
protected $table = "accounts";
public $pkey = 'id';
protected $salt = 'Salt';
protected $fillable = ['id', 'Username', 'Key'];
public $timestamps = false;
}
CustomAuthController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Auth;
class CustomAuthController extends Controller
{
//Login
public function showLoginForm()
{
return view('auth.login');
}
public function login(Request $request)
{
$this->validate($request, [
'username' => 'required|max:255',
'Key' => 'required|max:255',
]);
$user= User::where('Username', '=', $request->username)->get();
$hashedpw = hash('whirlpool', $request->Key);
if(Auth::attempt(['Username' => $request->username, 'Key' => $request->Key]))
{
return 'Logged in successfully';
}
else
{
return 'error'. $request->username. ' '. $user->Salt; #problematic variable <-
}
}
}
Thanks! Jack
Hi, Again.. I've narrowed down the problem although i cant figure out how to fix it.. If my account isn't logged in on my website i cant seem to access the salt column. But, if i'm logged into the site i can select it?..