title: parent id for category and subcategory
body: <p>I use L8 And I have a <code>category</code> table ,it has <code>parent_id</code> for my subcategories</p>
  <p><code>categories table</code></p>
  <p><code>Category model</code></p>
  <p><code>categoryController</code></p>
  <p><code>SubCategoryController</code></p>
  <p><code>categories.blade</code></p>
  <p><code>sub_categories.blade</code></p>
  <p>In my <code>subcategory-index.blade.php</code> I want to show categories but I just can show them with their id (parent id)</p>
  <p>I don't know how to show categories title instead of their id.</p>
  <p>I have this migration for categories table :</p>
  <pre><code>public function up()
      {
  
          Schema::dropIfExists('categories');
          Schema::create('categories', function (Blueprint $table) {
              $table-&gt;id();
              $table-&gt;unsignedBigInteger('parent_id')-&gt;default(123);
  
              $table-&gt;string('title');
              $table-&gt;longText('description');
              $table-&gt;tinyInteger('status')-&gt;comment('status is 1 when a category is active and it is 0 otherwise.')-&gt;nullable();
  
  
              $table-&gt;rememberToken();
              $table-&gt;softDeletes();
              $table-&gt;timestamps();
  
          });
      }
  
  </code></pre>
  <p>and this is my category model :</p>
  <pre><code>class Category extends Model
  {
      use HasFactory;
  
      protected $fillable = [
           'parent_id','title' , 'description', 'status',
      ];
  
      public function children(){
          return $this-&gt;hasMany(Category::class , 'parent_id');
      }
  
      public function post(){
          return $this-&gt;hasMany(Post::class);
      }
  }
  
  </code></pre>
  <p>And my subcategory controller :</p>
  <pre><code>...
  
  public function index()
      {
          $parent_id = Category::with('parent_id')-&gt;get();
          $subcategories = Category::where('parent_id' ,'!=', 123)-&gt;get();
           return view('admin.subcategories.subcategories-index' , compact('subcategories'));
      }
  ...
  
  </code></pre>
  <p>And the part for show subcategory title in category-index.blade.php :</p>
  <pre><code>&lt;table class=&quot;table table-bordered&quot;&gt;
          &lt;tr&gt;
              &lt;th&gt;#&lt;/th&gt;
              &lt;th&gt;id&lt;/th&gt;
              &lt;th&gt;title&lt;/th&gt;
              &lt;th&gt;category&lt;/th&gt;
              &lt;th&gt;status&lt;/th&gt;
              &lt;th&gt;operation&lt;/th&gt;
  
          &lt;/tr&gt;
  
          @foreach($subcategories as $subcategory )
          &lt;tr&gt;
              &lt;td&gt;{{ $loop-&gt;iteration }}&lt;/td&gt;
             &lt;td&gt;{{ $subcategory['id'] }}&lt;/td&gt;
             &lt;td&gt;{{ $subcategory['title'] }}&lt;/td&gt;
             &lt;td&gt;{{ $subcategory['parent_id']}}&lt;/td&gt;
             &lt;td&gt;
                 @if($subcategory['status']==0 or $subcategory['status']==NULL)
                  inactive
                 @else
                 active
                 @endif
             &lt;/td&gt;
             &lt;td&gt;
                 &lt;form method=&quot;POST&quot; action=&quot;{{ route('subcategory.destroy',$subcategory-&gt;id) }}&quot;&gt;
                     &lt;a class=&quot;btn btn-info&quot; href=&quot;{{ route('subcategory.show' , $subcategory-&gt;id) }}&quot;&gt;show&lt;/a&gt;
                     &lt;a class=&quot;btn btn-primary&quot; href=&quot;{{ route('subcategory.edit' , $subcategory-&gt;id) }}&quot;&gt;edit&lt;/a&gt;
                     @csrf
                     @method('DELETE')
                     &lt;button type=&quot;submit&quot; class=&quot;btn btn-danger&quot;&gt; delete&lt;/button&gt;
  
                 &lt;/form&gt;
             &lt;/td&gt;
          &lt;/tr&gt;
  
          @endforeach
  
      &lt;/table&gt;
  </code></pre>
  <p>Thanks for telling me what to do :&gt;</p>