/**
  * Handle the command.
  *
  * @param  StoreNewSnippetCommand  $command
  * @return void
  */
 public function handle(StoreNewSnippetCommand $command)
 {
     if (empty($command->title)) {
         $command->title = str_limit($command->body, 10);
     }
     $snippet = Snippet::create(['user_id' => $command->user_id, 'title' => $command->title, 'body' => $command->body, 'mode' => $command->mode, 'password' => $command->password]);
     SnippetSlug::create(['snippet_id' => $snippet->id, 'slug' => $snippet]);
     return $snippet;
 }
Esempio n. 2
0
 public function run()
 {
     $faker = Faker\Factory::create();
     $users = \DarkShare\Users\User::lists('id')->all();
     foreach (range(1, 100) as $index) {
         $snippet = Snippet::create(['user_id' => $faker->boolean() ? $faker->randomElement($users) : null, 'title' => $faker->sentence(), 'body' => $faker->paragraph(), 'mode' => 'markdown', 'password' => $faker->boolean() ? 'secret' : null]);
         SnippetSlug::create(['snippet_id' => $snippet->id, 'slug' => $snippet]);
     }
 }