title: Is it possible to call all while also finding id in Laravel?
body: <p>I wish to display the name of the category in the title section however I can't seem to call the specific Category::find($id) since I also have Category::all(). It works, however I can't display the category name.</p>
  <p>Here's my code.
  Controller</p>
  <pre><code>public function categorized($id)
  {
      $categories = Category::all();
      $category = Category::find($id);
      $businesses = Business::where('category_id', $category-&gt;id)-&gt;get()-&gt;sortBy('name');
      if (Auth::check()) {
      $userId = Auth::user()-&gt;id;
      $users = User::where('id', $userId)-&gt;get();
  
      return view('directories.categorized', [
          'categories' =&gt; $categories,
          'businesses' =&gt; $businesses,
          'users' =&gt; $users,
          ]);
      } else {
          return view('directories.categorized', [
              'categories' =&gt; $categories,
              'businesses' =&gt; $businesses,
          ]);
      }
  }
  </code></pre>
  <p>Blade</p>
  <pre><code>@extends('layouts.app')
  
  @section('title', &quot;$categories&quot;)
  
  @section('content')
  &lt;div style=&quot;margin-top: 40px;&quot;&gt;
      @foreach ($businesses as $business)
      &lt;a href='{{ url(&quot;/businessprofile/$business-&gt;id/&quot;.Str::slug($business-&gt;name)) }}'&gt;
          &lt;img src='{{ asset(&quot;storage/$business-&gt;logo&quot;) }}'&gt;
          &lt;h5&gt;{{ $business-&gt;name }}&lt;/h5&gt;
      &lt;/a&gt;
      @endforeach
  &lt;/div&gt;
  </code></pre>
  <p>@endsection</p>
  <p>If I put $categories-&gt;name it says that the name property is not found but if put foreach it simply gives the first data in categories table.</p>
  <p>While $categories, it just returns the array of my categories table</p>