title: Adding subcategories to laravel 5.4
body: <p>I have categories table in my application and it works just fine but i wonder how to get subcategories for that as well?</p>
  
  <p>currently what I have is:</p>
  
  <p>Category Model</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Category extends Model
  {
  
    protected $fillable = ['name'];
  
    public function ads(){
       return $this-&gt;hasMany(Ad::class);
    }
  
  }
  </code></pre>
  
  <p>Category Migration:</p>
  
  <pre><code>public function up()
      {
          Schema::create('categories', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;string('slug')-&gt;unique();
              $table-&gt;timestamps();
          });
      }
  </code></pre>
  
  <p>My Post Model:</p>
  
  <pre><code>public function category(){
         return $this-&gt;belongsTo(Category::class);
      }
  </code></pre>
  
  <p>PS: I know I have to make new table and call for foreign key of <code>category_id</code> for subcategories but what makes me confuse is the relationships and also how to select them in front-end so category and subcategories all shows in one drop down to user (like WP)?</p>