/**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     //TODO - this is little hacky here, but hey, it works.
     //When we update an instance....
     Instance::updating(function ($instance) {
         // Run reminders for that instance
         Log::info('Instance update event hook triggered');
         $reminderRunner = new ReminderRunner();
         $reminderRunner->runSymbolReminders($instance->symbol);
         // Update other instances of the same symbol
         //TODO - Actually make this work on same day instances?
         DB::table('instances')->where([['symbol_id', $instance->symbol->id], ['action', NULL]])->update(array('action' => 'dismiss', 'sentiment' => 'neutral', 'note' => 'Dismissed by reference from instance ID#' . $instance->id));
     });
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $instances = Instance::with('symbol')->get();
     return response()->json($instances);
 }
 /**
  * Create a new profile composer.
  *
  * @param  UserRepository  $users
  * @return void
  */
 public function __construct(Instance $instance, Symbol $symbol)
 {
     // Dependencies automatically resolved by service container...
     $this->instances = $instance->whereNull('action')->with('symbol')->orderBy('created_at', 'desc')->get();
     $this->instances = $this->instances->groupBy('source_name');
 }