Seeding your project
Local (development) seeder
To ease development of your project, you can use the OzuSeeder class to seed your local database with some dummy data:
php
use Code16\OzuClient\Support\Database\OzuSeeder;
// ...
class DatabaseSeeder extends OzuSeeder
{
public function run(): void
{
// this will delete any remaining seeded Media files
$this->clearMediaDirectory();
Project::factory()
->count(12)
->has(Media::factory()->image()->withFile(), 'cover')
->has(Media::factory()->image()->withFile()->count(3), 'visuals')
->sequence(fn ($sequence) => [
'order' => $sequence->index + 1,
'country' => fake()->country(),
])
->create();
// ...
}
}Production seeder
To ease the first deployment of your project, you can use the OzuProductionSeeder class to seed Ozu with some production data (i.e., coming from a previous version of your site):
php
use Code16\OzuClient\Support\Database\OzuProductionSeeder;
// ...
class ProductionSeeder extends OzuProductionSeeder
{
public function run(): void
{
// At this point, you'll have to create your real data. You're not forced to save
// it in your local database, since Ozu will accept a model without an ID and seed it in production.
$myRealProjects = Project::factory()
->count(12)
->has(Media::factory()->image()->withFile(), 'cover')
->has(Media::factory()->image()->withFile()->count(3), 'visuals')
->sequence(fn ($sequence) => [
'order' => $sequence->index + 1,
'country' => fake()->country(),
])
->make();
$myRealProjects
->each(fn($project) =>
$this->createInOzu($project)
->withFile(field: 'cover', path: $project->cover->file_name)
->withFileList(field: 'visuals', paths: $project->visuals->pluck('file_name')->toArray())
);
// ...
}
}Then you need to run the command:
shell
php artisan db:seed --class=ProductionSeederWARNING
Make sure your data is correct before running your production seeder because there's no simple way to bulk delete content from Ozu. You'll have to manually delete them from the Ozu CMS if you made a mistake.