title: Laravel belongsToMany - Get Parent All Categories
body: <p>I can not speak English well. Iam Sorry.
  i want to do, get all categories to which the category with id 5 is attached</p>
  <p>where is error editing ?</p>
  <p>Database:</p>
  <p><a href="https://i.stack.imgur.com/QBvx5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QBvx5.png" alt="Database ScreenShot" /></a>
  Categories.php</p>
  <pre><code>class Categories extends Model
  {
      use HasFactory;
      protected $fillable = [
          'name',
          'parent_id',
          'slug',
          'title',
          'description'
      ];
  
      public function parentCategories(){
          return $this-&gt;belongsToMany(Categories::class);
      }
  }
  </code></pre>
  <p>Controller</p>
  <pre><code>public function AddDetail(AdvertAddDetail $request){
      $selected = Categories::find($request-&gt;select);
      print_r($selected-&gt;parentCategories());
  }
  </code></pre>