Php Laravel Trying to get property of non object
<p>I am new in laravel. I got this error in my code.</p>

<p><img src="https://cloud.githubusercontent.com/assets/12628112/16941187/2a8a6e86-4dc1-11e6-8559-b8f47c17a11f.PNG" alt="capture">  </p>

<hr>

<p>DataController.php </p>

<hr>

<pre><code>// Get Affiliate Data
$data = Commission::where([
  'uploads_id' =&gt; $period ,
  'affiliate_code' =&gt; $id
])-&gt;first();

//Get Last Activity
$lastactivitytxt = null;
$lastactivity = Activity::where('text','LIKE','%Affiliate ['.$data-&gt;affiliate_name.']%'); //This is line 168
</code></pre>

<hr>

<p>Can someone tell me what is wrong with my code?</p>