我无法在我的播种机类中使用Auth。我需要为我的saas应用程序获取tenant_id变量。这是我的播种班。非复合名称'Auth'的使用声明不起作用laravel
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();
}
}
我打电话
$this->call(AccountTypeTableSeeder::class);
尝试'AUTH() - >用户() - > tenant_id',回来报告。 – Gammer
同样的错误,“非复合名称使用声明'Auth'没有影响laravel”。 – Wangchen
请发布完整文件 – Anders