SHARE
TWEET

Untitled

a guest Aug 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Auth;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\DB;
  6. use App\Http\Controllers\User;
  7. use App\MongoStudents;
  8.  
  9. class secretar extends Controller
  10. {
  11.     public function home(){
  12.  
  13.         // $userId = Auth::user()->id;
  14.  
  15.         $users['users'] = DB::table('users')->select('id', 'name')->get();
  16.         // print_r($users['users']);
  17.         // echo "<br>";
  18.  
  19.         $dateStudenti = array();
  20.         $userIdStudent = array();
  21.  
  22.         foreach($users['users'] as $user){
  23.  
  24.         // print_r($user->id); - afiseaza id-ul userilor 1:1138
  25.  
  26.         $studentsId['students'] = DB::table('Student2User')->where([
  27.             ['idStudent',$user->id],
  28.             ['idUser', '<>', '', 'and'],
  29.             ])->get();
  30.  
  31.            foreach($studentsId['students'] as $studentId)
  32.            {
  33.               // print($studentId->idUser);
  34.               // print($studentId->idStudent);
  35.               // echo "<hr>";
  36.               // afiseaza id-ul studentilor 445:6065
  37.               // Cred ca trebuie folosita si functia in_array
  38.  
  39.               array_push($dateStudenti, $studentId);
  40.               array_push($userIdStudent, $studentId->idStudent);
  41.             }
  42.         }
  43.  
  44.         // echo "<hr>";
  45.         // print_r($dateStudenti);
  46.    
  47.  
  48.         // echo "<br>";
  49.         $nrStudenti = count($dateStudenti);
  50.         // print_r($nrStudenti);
  51.  
  52.         // 800 801 802
  53.         // $studentId->idStudent
  54.  
  55.         // select from user name where id = studentId->idStudent[$i]
  56.  
  57.         // print_r($userIdStudent);
  58.  
  59.         if($nrStudenti > 0)
  60.         {
  61.             // foreach($idStudenti as $idStudent)
  62.             for($i=0; $i<$nrStudenti; $i++)
  63.             {
  64.  
  65.                 // print($dateStudenti[$i]->idUser);
  66.                 $studentName = DB::table('users')->select('name')->where('id', $userIdStudent[$i])->get();
  67.                 $MongoStudents = new MongoStudents();
  68.                 $sstud = (int)$dateStudenti[$i]->idUser;
  69.                 $mongo['student'] = MongoStudents::where('_id', $sstud)->get();
  70.                 $facAdmis = $mongo['student'][0]->admitereCandidat['facAdmis'];
  71.  
  72.                 $domeniuAdmis = $mongo['student'][0]->admitereCandidat['domeniuAdmis'];
  73.                 $domeniuAdmis = explode('-',$domeniuAdmis);
  74.                 $domeniu = $domeniuAdmis[0];
  75.                 $finantare = $domeniuAdmis[1];
  76.  
  77.              //    print_r($userIdStudent[$i]);
  78.                
  79.              //    print_r($studentName);
  80.              //    print_r($facAdmis);
  81.              //    print_r($mongo['student'][0]->_id);
  82.                 // print_r($domeniu);
  83.                 // print_r($finantare);
  84.                
  85.                 // print "<hr>";
  86.                
  87.                 $arrData[$i] = array(
  88.                          'id'=>$mongo['student'][0]->_id,
  89.                          'nume'=> $studentName[0]->name,
  90.                          'facAdmis'=> $mongo['student'][0]->admitereCandidat['facAdmis'],
  91.                          'domeniu'=> $domeniu,
  92.                          'finantare'=> $finantare,
  93.                  );
  94.                
  95.             }
  96.             $data=array(
  97.                  'nrStudenti'=>$nrStudenti,
  98.                  'informatii'=>$arrData
  99.             );
  100.         return view('secretari/acasaSecretar')->with('data', $data);
  101.         } else{
  102.             $data=array(
  103.                 'nrStudenti'=>0
  104.             );
  105.         return view('secretari/acasaSecretar')->with('data', $data);
  106.         }
  107.  
  108.         // print_r($data['informatii'][0]['nume']);
  109.                
  110. }
  111.  
  112.  
  113. // $mongo = new MongoStudents();
  114. //      $userId = Auth::user()->id;
  115. //         $idStudentAll = DB::table('Student2User')->select('idStudent')->where('idUser', $userId)->get();
  116. //         $rol = DB::table('AsignareRol')->select('idRol')->where('idUser', $userId)->get();
  117. //          $idStudent = $idStudentAll[0]->idStudent;
  118. //      $mongo['student'] = MongoStudents::where('_id', $idStudent)->get();
  119. //      $facAdmis = $mongo['student'][0]->admitereCandidat['facAdmis'];
  120. //      $domeniuAdmis = $mongo['student'][0]->admitereCandidat['domeniuAdmis'];
  121.        
  122.     public function adeverinte(){
  123.         return view('secretari/adeverinte');
  124.     }
  125. }
  126.  
  127. // <!--  <?php
  128. // namespace App\Http\Controllers;
  129. // use Auth;
  130. // use Illuminate\Http\Request;
  131. // use Illuminate\Support\Facades\DB;
  132. // use App\Http\Controllers\User;
  133. // use App\MongoStudents;
  134. // use Illuminate\Database\Eloquent\Model;
  135. // use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
  136. // use Illuminate\Support\Facades\Route;
  137. // class secretar extends Controller
  138. // {
  139.    // public function home(){
  140.    //   $mongo = new MongoStudents();
  141.    //   //  $userId = Auth::user()->id;
  142.        
  143.    //     $usersId['users'] = DB::table('users')->select('id','name')->where('id',800)->get();
  144.    //     // print_r($usersId['users'][0]->id);
  145.    //     // echo "<br>";
  146.    //     $userIdd = $usersId['users'][0]->id;
  147.  
  148.  
  149.  
  150.  
  151.  
  152. //        $ids = DB::table('Student2User')->pluck('idUser');
  153.  
  154. //        foreach ($ids as $idUser) {
  155. //             echo "<br>".$idUser;
  156. // }
  157.  
  158.        // $studentsId['students']= DB::table('Student2User')->select('idUser')->where('idStudent',$userIdd)->get();
  159.        // $stud=(int)$studentsId['students'][0]->idUser;
  160.        // print_r($stud);
  161.  
  162.        // $mongo['student'] = MongoStudents::where('_id', '=', $stud)->get();
  163.        // print_r($mongo['student'][0]->admitereCandidat['facAdmis']);
  164.        // // $facAdmis = $mongo['student'][0]->admitereCandidat['facAdmis'];
  165.        // $domeniuAdmis =  $mongo['student'][0]->admitereCandidat['domeniuAdmis'];
  166.        // $domeniuAdmis = explode('-',$domeniuAdmis);
  167.        // $domeniu = $domeniuAdmis[0];
  168.        // $finantare = $domeniuAdmis[1];
  169.  
  170.        // print_r($finantare);
  171.       // $justUsersId['users'] = $usersId['users']->
  172.  
  173.        // $idStudenti = array();
  174.        // foreach($usersId['users'] as $user){
  175.        //     // print_r($user->id);
  176.        //     echo "<br>";
  177.        //     $studentsId['students'] = DB::table('Student2User')->select('idUser')->where('idStudent','=',$user->id)->get();
  178.        //     // Cred ca trebuie folosita si functia in_array
  179.        //     array_push($idStudenti, $studentsId['students']);
  180.        // }
  181.        // // $justUsersId['users'] = $usersId['users']->
  182.        //     // $studentsId['students'] = DB::table('Student2User')->select('idUser')->where('idStudent','=',$userrId['users'][0]->id)->get();
  183.        //     // print_r($studentsId['students']);
  184.        // // In coloana asta avem toti studentii din anu 1
  185.        // // $idStudentAll = DB::table('Student2User')->select('idStudent')->where('idUser', $userId)->get();
  186.        // echo "<hr>";
  187.       // $nrStudenti = count($idStudenti);
  188.        // print_r($nrStudenti);
  189.        // // $mongo = new MongoStudents();
  190.     //    $mongo['student'] = MongoStudents::where('_id', $studentsId['students'])->get();
  191.     //    $facAdmis = $mongo['student'][0]->admitereCandidat['facAdmis'];
  192.     //    $domeniuAdmis = $mongo['student'][0]->admitereCandidat['domeniuAdmis'];
  193.     //    $domeniuAdmis = explode('-',$domeniuAdmis);
  194.     //    $domeniu = $domeniuAdmis[0];
  195.     //    $finantare = $domeniuAdmis[1];
  196.        // $nrStudenti= count($students['datePersonale']);
  197.    //     if($nrStudenti > 0){
  198.    //      for( $i=0; $i< $nrStudenti; $i++)
  199.    //      {
  200.    //          $idStudent = ($i+1);
  201.    //          $numeStudent = DB::table('datePersonale') -> where('idStudent',$idArticol)->get();
  202.    //     }
  203.    // }
  204.    // return view('secretari/acasaSecretar')->with('nr', $nrStudenti);
  205. //    public function adeverinte(){
  206. //        return view('secretari/adeverinte');
  207. //    }
  208. // } --> -->
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top