Exemplo n.º 1
0
 public function search($search, $id)
 {
     if (!empty($search)) {
         $entries = $this->entry->join('users', 'users.id', '=', 'entries.user_id')->where('users.name', 'LIKE', '%' . $search . '%')->where('project_id', '=', $id);
         if ($entries->count() > 0) {
             return $entries->paginate(5);
         } else {
             $entries = $this->entry->join('users', 'users.id', '=', 'entries.user_id')->where('users.email', 'LIKE', '%' . $search . '%')->where('project_id', '=', $id);
             if ($entries->count() > 0) {
                 return $entries->paginate(5);
             }
         }
     }
 }
Exemplo n.º 2
0
 public function query($id)
 {
     if (!empty($id)) {
         $users = $this->entry->select('*')->join('projects', 'projects.id', '=', 'entries.project_id')->join('entry_free', 'entries.id', '=', 'entry_free.entry_id')->join('frees', 'entry_free.free_id', '=', 'frees.id')->where('projects.id', $id)->get();
         if ($users->count() > 0) {
             $entry = $this->entry->find($id);
             $protocol = $entry->project->protocol->protocol_number;
             $file = 'export_frees/01757321000106_' . $protocol . '_' . date('dmY') . '_001.txt';
             foreach ($users as $user) {
                 $contents = $user->nome . ';' . $user->nis . ';' . $user->datadenascimento . ';' . $user->sexo . ';' . $user->num_identid_rg . ';' . $user->dt_identid_rg . ';' . $user->sg_em_identid_rg . ';' . $user->cpf . ';' . $user->nomedamae . ";\r\n";
                 $bytes_written = File::append($file, $contents);
                 if ($bytes_written === false) {
                     die("Error writing to file");
                 }
             }
             return $file;
         }
     }
 }