@fahmidotexe Can you paste your seeder and factories that you're running?
The premise is replace the foreign key in the factory, eg user_id, with a model.
I'm working on a Laravel 9 project with Jetstream and setting up Spatie Permissions package. The following code worked for me. Hopefully it will help someone else looking to do something similar. I have this code in my UserTableSeeder class.
public function run()
{
$user = User::create([
// populate user fields
]);
// This code is taken from "App\Actions\Fortify\CreateNewUser.php"
$user->ownedTeams()->save(Team::forceCreate([
'user_id' => $user->id,
'name' => explode(' ', $user->name, 2)[0]."'s Team",
'personal_team' => true,
]));
}