Laravel passing variables from one seed file to another?

I have created multiple seed files and my main DatabaseSeeder file looks like this:


use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
     * Run the database seeds.
     * @return void
    public function run()
        $name1 = "James";
        $name2 = "Jeff";
        $name3 = "Joe";


How can I make it so that UserTableSeeder and PersonTableSeeder gets the variables from my main seeder file? (What I'm really trying to do is use Faker to output random values, but use the same value for each table seeder)

Read more here:

Content Attribution

This content was originally published by Sosa at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: