/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     IrcLog::drop();
     $this->call('EnsureIndexesSeeder');
     $this->call('LogsSeeder');
 }
Example #2
0
 /**
  * Generate messages
  */
 public function generate()
 {
     $log = array('type' => $this->faker->randomElement(static::$TYPES), 'nick' => $this->faker->userName, 'time' => new MongoDate($this->faker->dateTimeThisYear->getTimestamp()));
     $messageKey = $log['type'] == 'message' ? 'text' : ($log['type'] == 'quit' ? 'reason' : null);
     if ($messageKey) {
         $log[$messageKey] = $this->faker->sentence(rand(3, 50));
     }
     IrcLog::insert($log);
 }
 /**
  * Ajax infinite loading
  */
 public function infinite($direction, $id)
 {
     $log = IrcLog::findOneOrFail($id);
     // Build the query to fetch logs with
     list($filter, $sort) = $direction == 'up' ? array('$lt', -1) : array('$gt', 1);
     // Fetch the logs
     $logs = IrcLog::find(array('time' => array($filter => $log->time)))->sort(array('time' => $sort))->limit($this->ajaxLoad)->all();
     $loadMore = null;
     if (count($logs) == $this->ajaxLoad) {
         $loadMore = end($logs)->_id;
     }
     if ($direction == 'up') {
         $logs = array_reverse($logs);
     }
     return View::make('partials.logs')->with('logs', $logs)->with('more' . $direction, $loadMore);
 }
 public function run()
 {
     IrcLog::ensureIndex(array('text' => 'text'));
     IrcLog::ensureIndex(array('time' => 1));
 }