Created
October 16, 2020 21:28
-
-
Save duncanmcclean/cef26fa418296de633f8a15beae66c98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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