title: Check SHA-256 Laravel
body: <p>I have a system that requires a homeowner to submit a form about their guest's details. When they submit a form, each will be assigned a unique 6-digit code. This code will be hashed with SHA-256. In the admin's view, there is a list of all submitted forms. I want to do a search function where when I enter the code, the system will look through the hashed code and check if it exists or not.</p>
  <p>This is my GuestController:</p>
  <pre><code>public function index()
      {
          //returns admin's view
          $guest = Guest::all();
          return view('pages.guest.index', compact('guest'));
      }
  public function store(Request $request)
      {
          $guest = new Guest;
          $guest-&gt;code = random_int(100000, 999999);
          $guest-&gt;hash = hash('sha256', $guest['code']);  
          $guest-&gt;owner_id = Auth::user()-&gt;id;
          $guest-&gt;owner = Auth::user()-&gt;name;
          $guest-&gt;unit = Auth::user()-&gt;unit;
          $guest-&gt;guestname = $request-&gt;input('guestname');
          $guest-&gt;guestphone = $request-&gt;input('guestphone');
          $guest-&gt;guestic = $request-&gt;input('guestic');
          $guest-&gt;guestcar = $request-&gt;input('guestcar');
          $guest-&gt;numberofguests = $request-&gt;input('numberofguests');
          $guest-&gt;datevisit = $request-&gt;input('datevisit');
          $guest-&gt;timevisit = $request-&gt;input('timevisit');
          $guest-&gt;save();
          
          return redirect('show-pass')-&gt;with('status', 'Guest Added Successfully');
      }
  public function search(Request $request)
      {
          //Get the search value from the request
          $search = $request-&gt;input('search');
  
          //Search in the code from the list
          $guest = Guest::query()
                  -&gt;where('code', 'LIKE', &quot;%{$search}%&quot;)
                  -&gt;get();
                 
          //Return the search view with the results compacted
          return view('pages.guest.search', compact('guest'));
  
      }
  </code></pre>
  <p>This is my search result blade:</p>
  <pre><code>&lt;div class=&quot;card-body&quot;&gt;
                  @if($guest-&gt;isNotEmpty())
                          @foreach ($guest as $item)
                              &lt;div class=&quot;post-list&quot;&gt;          
                                  &lt;p&gt;Owner : {{ $item-&gt;owner }}&lt;/p&gt;
                                  &lt;p&gt;Unit : {{ $item-&gt;unit }}&lt;/p&gt;                 
                                  &lt;p&gt;Guest Name : {{ $item-&gt;guestname }}&lt;/p&gt;
                                  &lt;p&gt;Guest Phone Number : {{ $item-&gt;guestphone }}&lt;/p&gt;
                                  &lt;p&gt;Guest IC Number : {{ $item-&gt;guestic }}&lt;/p&gt;
                                  &lt;p&gt;Guest Car Number : {{ $item-&gt;guestcar }}&lt;/p&gt;
                                  &lt;p&gt;Date : {{ $item-&gt;datevisit }}&lt;/p&gt;
                                  &lt;p&gt;Time : {{ $item-&gt;timevisit }}&lt;/p&gt;
                              &lt;/div&gt;
                          @endforeach
                          @else 
                          &lt;div&gt;
                          &lt;h4&gt;No guests with the code was found&lt;/h4&gt;
                          &lt;/div&gt;
                  @endif
               &lt;/div&gt;
  </code></pre>
  <p>Is what I'm trying to do possible? If yes, how can I edit my search method to be able to do so? May I get some help?</p>