private function registerFactories()
 {
     $factory = $this->app->make(Factory::class);
     $factory->define(Category::class, function (Faker $faker) {
         $name = $faker->colorName;
         return ['name' => $name, 'slug' => str_slug($name)];
     });
     $factory->define(Post::class, function (Faker $faker) {
         $userIds = $this->getUserModel()->lists('id')->toArray();
         $categoryIds = Category::lists('id')->toArray();
         $name = $faker->realText(40);
         return ['title' => $name, 'slug' => str_slug($name), 'type' => Post::TYPE_TEXT, 'content' => $faker->realText(400), 'user_id' => $faker->randomElement($userIds), 'category_id' => $faker->randomElement($categoryIds), 'published_at' => Carbon::now()->addDays(rand(0, 2))];
     });
 }
 /**
  * Get all categories ordered by their popularity.
  *
  * @return \Illuminate\Support\Collection
  */
 public function getAllOrderByPopularity($descending = true)
 {
     return $this->model->popular($descending)->get();
 }