Skip to content

Instantly share code, notes, and snippets.

@duncanmcclean
Created October 16, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duncanmcclean/cef26fa418296de633f8a15beae66c98 to your computer and use it in GitHub Desktop.
Save duncanmcclean/cef26fa418296de633f8a15beae66c98 to your computer and use it in GitHub Desktop.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Faker\Factory;
use Statamic\Facades\Entry;
use Illuminate\Support\Str;
class CreateFakeEntries extends Command
{
protected $faker;
protected $signature = 'fake:entries';
protected $description = 'Create a bunch of fake entries.';
public function __construct()
{
parent::__construct();
$this->faker = Factory::create();
}
public function handle()
{
for ($i = 0; $i < 160; $i++) {
$this->info("Creating {$i}th entry");
$title = $this->faker->sentence();
$slug = Str::slug($title);
Entry::make()
->collection('pages')
->slug($slug)
->data([
'title' => $title,
'description' => $this->faker->paragraph(),
])
->save();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment