public function run() { $faker = Faker\Factory::create(); $users = User::lists('id')->all(); foreach (range(1, 100) as $index) { $url = Url::create(['user_id' => $faker->boolean() ? $faker->randomElement($users) : null, 'destination' => $faker->url, 'password' => $faker->boolean() ? 'secret' : null]); UrlSlug::create(['url_id' => $url->id, 'slug' => $url]); } }
/** * Handle the creation of a new URL * * @param StoreNewUrlCommand $command * @return void */ public function handle(StoreNewUrlCommand $command) { $url = Url::create(['user_id' => $this->auth->user() ? $this->auth->user()->id : null, 'destination' => $command->destination, 'password' => $command->password]); UrlSlug::create(['url_id' => $url->id, 'slug' => $url]); return $url; }