You don't need this:
use Auth;
It is helpful to think of this as aliasing rather than importing.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am unable to use Auth in my seeder class. I need to use tenant_id for my saas application. Here's my seeder class.
use Illuminate\Database\Seeder; use App\AccountType; use Auth;
class AccountTypeTableSeeder extends Seeder {
public function run()
{
$accountType = new AccountType;
$accountType->name = 'Travel Agent';
$accountType->description = 'It is the description of the Travel Agent, so you write in detaisl about the account type.';
$accountType->tenant_id = Auth::user()->tenant_id;
$accountType->save();
}
}
@wangchen You’re not going to have an authenticated user in a seeder class. A user doesn’t “log in” when you running seeds.
Please or to participate in this conversation.