@mitchelljulie thank you for your response . Sorry i cant get it what u said
Kindly get u slightly explain
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Guys iam working with a project job portal site.
for job seeker i done manual authentication with user table
this is my controller for manual authentication process
public function store(Request $request)
{
if (auth()->attempt(request(['email', 'password'])) == false) {
return back()->withErrors([
'message' => 'The email or password is incorrect, please try again'
]);
}
return redirect()->route('login_logout.index');
}
this works fine. perfectly authenticating and logging the user.
this is my model for that user 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 $fillable = [
'user_type','email', 'mobile_number', 'password','type','first_name','last_name','progress_value','is_accepted',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* Add a mutator to ensure hashed passwords
*/
public function setPasswordAttribute($password)
{
$this->attributes['password'] = bcrypt($password);
}
}
Now i need to authenticate employer registration.
i created a model EmployerUser
this is my model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class EmployerUser extends Model
{
//
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_type','email_id', 'mobile', 'password','is_accepted',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* Add a mutator to ensure hashed passwords
*/
public function setPasswordAttribute($password)
{
$this->attributes['password'] = bcrypt($password);
}
}
and i inserted data with the cotroller.
$employer_user = EmployerUser::create([
'email_id' => $request->email_id,
'mobile' => $request->mobile,
'password' =>$request->mobile,
'user_type'=>'Employer',
'is_accepted'=>0,
]);
this also worked fine.
but when it comes to authentication. there comes the problem
this is what i did to authenticate employer
public function employer_login(Request $request)
{
if (auth()->attempt(request(['email', 'password'])) == false) {
return back()->withErrors([
'message' => 'The email or password is incorrect, please try again'
]);
}
return redirect()->route('Employer-registration.index');
}
But this is authenticating with user table..
what can i do
i placed employeruser()
here
if (auth()->employeruser()->attempt(request(['email', 'password'])) == false)
but showing error
Method employeruser does not exist.
how can i authenticate
and after login in my user i used this to fetch all records $user = Auth::user(); this fetched all records.
but if i give $employeruser = Auth::employeruser (); it showing the same error
Method employeruser does not exist.
What should i do??
Kindly some one help please..
He's just throwing out random stuff... no real idea of the problem.
You have made life difficult for yourself by having two tables. I always treat all users the same but have additional properties to differentiate them.
If you wish to persist with multiple auths then you are going to have to put some work in to resolve all the issues. Google for Laravel Multi-Auth for some ideas.
Please or to participate in this conversation.