create(); $user = User::factory()->create([ 'account_id' => $account->id, 'confirmation_code' => '123', 'email' => $faker->safeEmail(), 'first_name' => 'John', 'last_name' => 'Doe', ]); $company = Company::factory()->create([ 'account_id' => $account->id, ]); $user->companies()->attach($company->id, [ 'account_id' => $account->id, 'is_owner' => 1, 'is_admin' => 1, 'is_locked' => 0, 'permissions' => '', 'notifications' => CompanySettings::notificationDefaults(), //'settings' => DefaultSettings::userSettings(), 'settings' => null, ]); $nmo = new NinjaMailerObject; $nmo->mailable = new MaxCompanies($user->account->companies()->first()); $nmo->company = $user->account->companies()->first(); $nmo->settings = $user->account->companies()->first()->settings; $nmo->to_user = $user; NinjaMailerJob::dispatchSync($nmo); } }