PHP code example of riley19280 / persistent-seeders
1. Go to this page and download the library: Download riley19280/persistent-seeders library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
riley19280 / persistent-seeders example snippets
class RoleSeeder extends PersistentSeeder {
#[SeederId('6f7b4e00-97d9-4cb0-8a6b-c092e73755e3')]
function initialRoles() {
Role::create(['name' => 'Admin']);
Role::create(['name' => 'User']);
}
}
class RoleSeeder extends PersistentSeeder {
#[SeederId('6f7b4e00-97d9-4cb0-8a6b-c092e73755e3')]
function initialRoles() {
Role::create(['name' => 'Admin']);
Role::create(['name' => 'User']);
}
#[SeederId('ef97efe9-40bd-4948-a1cd-feeb8fb1b27f')]
function managerRole() {
Role::create(['name' => 'Manager']);
}
}
class ProductionSeeder extends Seeder
{
public function run(): void
{
// Each of these is a PersistentSeeder
$this->call(TenantSeeder::class);
$this->call(RoleSeeder::class);
$this->call(UserSeeder::class);
}
}