Beispiel #1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $reader = Reader::createFromPath($this->path);
     $read = 0;
     $saved = 0;
     foreach ($reader->fetchAssoc() as $row) {
         $read++;
         $artist = Artist::firstOrNew(['artist_id' => $row['artist_id']]);
         $artist->artist_id = $row['artist_id'];
         $artist->slug = $row['slug'];
         $artist->name = $row['name'];
         $artist->PID = $row['PID'];
         $artist->year_birth = $row['year_birth'];
         $artist->year_death = $row['year_death'];
         $artist->copyright = $row['copyright'];
         if ($artist->save()) {
             $saved++;
         }
     }
     $report = ['event' => 'artists.imported', 'data' => ['read' => $read, 'saved' => $saved]];
     $message = json_encode($report);
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:5555");
     $socket->send($message);
 }
Beispiel #2
0
 public function count()
 {
     return Artist::orderBy('name', 'asc')->count();
 }