title: Display notification when database has new row, Laravel
body: <p>I am trying to send a notification to a user when a database table has a new row. But I have two problem. </p>
  
  <h2>UPDATED</h2>
  
  <p>First problem is with the script below. I can send notification only if I run this route's url. <code>Route::get('/car/create', 'CarController@carNews');</code> Not when I update my DB table... How can I change this to send notification not by run the url, but by update the DB table... (also trying not to send the whole table, just new added rows.)</p>
  
  <p><strong>Controller</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>public function __construct()
  {
      $this-&gt;middleware('auth');
  }
  
  public function carNews()
  {
      $cars = \DB::table('cars')-&gt;get();
  
      $user = User::first();
  
      $user-&gt;notify(new CarNews($cars));
  
      dd($user-&gt;notifications);
  }
  </code></pre>
  
  <p>The second problem is about displaying the notification in blade. I can't reach inside of the data column in notifications table in DB.</p>
  
  <pre class="lang-php prettyprint-override"><code>@foreach(auth()-&gt;user()-&gt;unreadNotifications as $notification)
       &lt;a href="#" class="dropdown-item"&gt;
              {{$notification-&gt;data-&gt;cars[0]['price']}}
       &lt;/a&gt;
  @endforeach
  </code></pre>
  
  <p>this giving me below error. </p>
  
  <blockquote>
    <p>Trying to get property of non-object</p>
  </blockquote>
  
  <p>By the way when I try to reach the data like this. <code>{{$notification-&gt;data}}</code> I am having this error. </p>
  
  <blockquote>
    <p>htmlspecialchars() expects parameter 1 to be string, array given</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/Gk9Ey.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gk9Ey.png" alt="enter image description here"></a></p>
  
  <p>The column look like this: My path is wrong?</p>
  
  <p>PS: if you need to see any other files, comment below. </p>