Make a function containing blade syntax
<p>I have this blade in my view. Right now, I have 6 blocks of them in my view because I'm not sure how to refactor it.</p>

<pre><code>&lt;div class="row filemanager"&gt;
&lt;div class="col-sm-12"&gt;
  @foreach ($devices as $device)
      @if( $device-&gt;vlan_id == 100 AND $device-&gt;device_activity == 'ACTIVE' )
        &lt;div class="col-xs-6 col-sm-4 col-md-2 text-center"&gt;
          &lt;div class="thmb"&gt;
            &lt;div class="btn-group fm-group" style="display: none;"&gt;
                &lt;button type="button" class="btn btn-default dropdown-toggle fm-toggle" data-toggle="dropdown"&gt;
                  &lt;span class="caret"&gt;&lt;/span&gt;
                &lt;/button&gt;
                &lt;ul class="dropdown-menu fm-menu" role="menu"&gt;
                  &lt;li id="device-menu"&gt;
                  &lt;a class="changeDeviceNameBtn" href="#"&gt;&lt;i class="fa fa-pencil"&gt;&lt;/i&gt; Change Device Name &lt;/a&gt;
                  &lt;/li&gt;
                &lt;/ul&gt;
            &lt;/div&gt;
            &lt;div class="thmb-prev"&gt;
              &lt;a href="/{{$cpe_mac}}/device/{{$device-&gt;device_mac}}"&gt;

              @if(isset($device-&gt;device_name))

              {{-- Show base on device name --}}
              &lt;img src="/images/photos/devices/{{img($device-&gt;device_name)}}.jpg" class="draggable img-responsive" alt=""&gt;

              @else

                  {{-- No Device Name Set --}}
                  @if($device-&gt;hostname != '')

                    {{-- Show base on hostname --}}
                    &lt;img src="/images/photos/devices/{{img($device-&gt;hostname)}}.jpg" class="draggable img-responsive" alt=""&gt;

                  @else

                    {{-- Show default --}}
                    &lt;img src="/images/photos/devices/no-img.jpg" class="draggable img-responsive" alt=""&gt;

                  @endif


              @endif

              &lt;/a&gt;
            &lt;/div&gt;
            &lt;h5 class="fm-title device_name"&gt;
              &lt;a href="/{{$cpe_mac}}/device/{{$device-&gt;device_mac}}"&gt;
              @if($device-&gt;hostname == '')
              No Devicename
              @else
              {{ $device-&gt;hostname}}
              @endif

              &lt;/a&gt;
            &lt;/h5&gt;
            &lt;h5 class="text-muted device_ip"&gt;{{$device-&gt;ip_address}}&lt;/h5&gt;
            &lt;h5 class="text-muted device_mac"&gt;{{$device-&gt;device_mac}}&lt;/h5&gt;

              &lt;?php
                  $status = ucfirst(strtolower($device-&gt;device_activity));
                  if ($status == 'Active'){
                      $color = '#1CAF9A';
                  }else{
                      $color = '#D9534F';
                  }
              ?&gt;

              &lt;h5&gt;{{ $status }}
                &lt;i class="fa fa-circle" style="color:{{$color}}; margin-left: 7px;"&gt;&lt;/i&gt;
              &lt;/h5&gt;


          &lt;/div&gt;
        &lt;/div&gt;

        @endif
      @endforeach

&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<hr>

<p>I want to make a function containing that blade, and only replace my </p>

<p><code>$device-&gt;vlan_id</code>, and my <code>$device-&gt;device_activity</code>. </p>

<p>Example, </p>

<pre><code>public static deviceRow(100,ACTIVE){

... my blade ... 

}
</code></pre>

<p>Now, I just that function 6 times, rather than duplicate that block of code 6 times.</p>

<p>Is it even possible ? </p>

<p>Any hints / suggestions on this will be much appreciated ! </p>