title: Laravel 5.7 sending notifications using Expo
body: <p>I'm using Laravel 5.7 for my backend (I'm new to Laravel) and I'm trying to use <a href="https://github.com/Alymosul/laravel-exponent-push-notifications" rel="nofollow noreferrer">Expo push notification extension for Laravel</a> to send notifications to my users.</p>
  
  <p>I followed the steps explained, but I get lost to where I'm suppose to place the <code>class ExpoNotification extends Notification</code> and how to call it.</p>
  
  <p>What I expect to happen is that every time an orders status get changed a notification is send to the user.</p>
  
  <p>What is happening is that I get an error saying the <code>class</code> can't be found.</p>
  
  <p><strong>OrderController</strong></p>
  
  <pre><code>    public function update_order(Request $request, $id)
      {
          //Get the Order and update the status
          Order::where('id', '=', $id )-&gt;update($request-&gt;only(['status']));
  
          //Get the order with ::find so I can use $order-&gt; 
          $order = Order::find($id);
  
          //Get user belonging to this order
          $user= User::where('id', '=', $order-&gt;user_id);
  
          //Get response with orders only posted the same day and are payed
          $orders = Order::where('store_id', '=', $order-&gt;store_id)
            -&gt;where('day', '=', $order-&gt;day )
            -&gt;where('week', '=', $order-&gt;week )
            -&gt;where('year', '=', $order-&gt;year )
            -&gt;where('payment_status', '=', $order-&gt;payment_status)-&gt;get();
  
          //send expo notification so the user gets his update
          new ExpoNotification($order);
  
          //return only relevant orders to the store
        return  OrderResource::collection($orders);
      }
  </code></pre>
  
  <p><strong>ExpoNotification</strong></p>
  
  <pre><code>&lt;?
  namespace App\Notifications\ExpoNotification;
  use App\Order;
  use App\User;
  use NotificationChannels\ExpoPushNotifications\ExpoChannel;
  use NotificationChannels\ExpoPushNotifications\ExpoMessage;
  use Illuminate\Notifications\Notification;
  
  class ExpoNotification extends Notification
  {
      public function via($notifiable)
      {
          return [ExpoChannel::class];
      }
  
      public function toExpoPush($notifiable)
      {
          return ExpoMessage::create()
              -&gt;badge(1)
              -&gt;enableSound()
              -&gt;body("Your {$notifiable-&gt;service} account was approved!");
      }
  }
  </code></pre>
  
  <p><strong>Error from postman</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;&lt;!--
  
  
  Symfony\Component\Debug\Exception\FatalThrowableError: Class &amp;#039;App\Notifications\ExpoNotification&amp;#039; not found in file /Users/salmanmohamed/Documents/apps/rapiobackend/app/Http/Controllers/OrderController.php on line 182
  Stack trace:
   1. Symfony\Component\Debug\Exception\FatalThrowableError-&amp;gt;() /Users/salmanmohamed/Documents/apps/rapiobackend/app/Http/Controllers/OrderController.php:182
  </code></pre>
  
  <p><strong>Answer</strong>
  Provided by Mohammed</p>
  
  <pre><code>&lt;?php
  
  namespace App\Notifications;
  
  use App\Order;
  use App\User;
  
  use Illuminate\Bus\Queueable;
  use Illuminate\Notifications\Notification;
  use Illuminate\Contracts\Queue\ShouldQueue;
  use Illuminate\Notifications\Messages\MailMessage;
  use NotificationChannels\ExpoPushNotifications\ExpoChannel;
  use NotificationChannels\ExpoPushNotifications\ExpoMessage;
  
  class ExNotification extends Notification
  {
      use Queueable;
  
      protected $order;
      public function __construct($order){
      $this-&gt;order=$order;
      }
  
      public function via($notifiable)
      {
          return [ExpoChannel::class];
      }
  
      public function toExpoPush($notifiable)
      {
          return ExpoMessage::create()
              -&gt;badge(1)
              -&gt;enableSound()
              -&gt;body("Your {$notifiable-&gt;service} account was approved!");
      }
  
      public function toArray($notifiable)
      {
          return [
              //
          ];
      }
  }
  
  </code></pre>