Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     foreach (Auth::user()->schools()->lists('school_id')->toArray() as $k => $v) {
         $value = $v;
     }
     $countStudent = School::where('id', '=', $value)->students->count();
     if (session()->has('message')) {
         Session::flash('noResults', 'Sorry, we found 0 results');
     }
     return view('student.index', compact('countStudent'));
 }
Example #2
0
 public function view($route, $title, $notices, $school)
 {
     $user = \Auth::user();
     $admin_schools = null;
     $client_schools = null;
     $administrator = \App\Administrator::where('user_id', $user->id)->first();
     $clients = \App\Client::where('user_id', $user->id)->get();
     if ($administrator != null) {
         $admin_schools = \App\School::where('id', $administrator->school_id)->first();
     }
     $schools = \Auth::user()->schools()->get();
     //dd($school);
     return view($route, compact('school', 'admin_schools', 'schools', 'clients', 'title', 'notices'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $request = request();
     $name = $request->has('name') ? $request->get('name') : '';
     $email = $request->has('email') ? $request->get('email') : '';
     $schools = School::where(function ($query) use($name, $email) {
         if (!empty($name)) {
             $query->where('name', 'LIKE', "%{$name}%");
         }
         if (!empty($email)) {
             $query->where('email', 'LIKE', "%{$email}%");
         }
     })->paginate(env('LIMIT', 15));
     return view('schools.index', compact('schools', 'name', 'email'));
 }
Example #4
0
 private static function storeSchoolsInCache()
 {
     $client = new Client();
     $res = $client->request("GET", "http://opendata.mpn.gov.rs/get.php?dataset=vsustanove2016&lang=sr&term=json");
     $schools = json_decode($res->getBody());
     $res = $client->request("GET", "http://opendata.mpn.gov.rs/get.php?dataset=sprogrami2016&lang=sr&term=json");
     $study_programs = json_decode($res->getBody());
     foreach ($schools as $key => $school) {
         if (!self::isInBelgrade($school->univerzitet, $school->nazivu) || self::notNeeded($school->id)) {
             unset($schools[$key]);
             continue;
         }
         //Convert from cyrilic to latin
         $school->nazivu = self::cyrilicToLatin($school->nazivu);
         $school->univerzitet = self::cyrilicToLatin($school->univerzitet);
         $school->adresa = self::cyrilicToLatin($school->adresa);
         $school->dekan = self::cyrilicToLatin($school->dekan);
         $school_from_db = School::where("id", $school->id)->first();
         if ($school_from_db != null) {
             $schools[$key]->bus = $school_from_db->bus;
             $photos = [];
             foreach ($school_from_db->photos as $photo) {
                 $photos[]['location'] = $photo->location;
             }
             $schools[$key]->photos = $photos;
         }
         $school->study_programs = [];
         $school->trajanje = [];
         foreach ($study_programs as $study_program) {
             if ($study_program->id == $school->id) {
                 $school->study_programs[] = ['naziv' => self::cyrilicToLatin($study_program->naziv), 'nivo' => self::cyrilicToLatin($study_program->nivo), 'trajanje' => self::cyrilicToLatin($study_program->trajanje), 'polje' => self::cyrilicToLatin($study_program->polje), 'zvanje' => self::cyrilicToLatin($study_program->zvanje), 'skolarina' => self::cyrilicToLatin($study_program->skolarina)];
                 $school->polje = self::cyrilicToLatin($study_program->polje);
                 if (!in_array($study_program->trajanje, $school->trajanje)) {
                     $school->trajanje[] = $study_program->trajanje;
                 }
             }
         }
     }
     //Store in cache for 7 days
     Cache::remember('schools', 10080, function () use($schools) {
         return $schools;
     });
     return array_values($schools);
 }
Example #5
0
 public function getClientMessages($school, $client)
 {
     $user = \Auth::user();
     $admin_schools = null;
     $client_schools = null;
     $administrator = Administrator::where('user_id', $user->id)->first();
     $clients = Client::where('user_id', $user->id)->get();
     if ($administrator != null) {
         $admin_schools = School::where('id', $administrator->school_id)->first();
     }
     //dd($client_schools);
     $schools = \Auth::user()->schools()->get();
     $post = "/" . $school->username . "/client/forum/" . $client->id . "/";
     $messages = $this->messages($school, 0);
     $client_messages = $this->messages($school, 1, $client->class);
     $title = "School Space";
     // dd($client_messages);
     return view('client.account.messenger', compact('title', 'client_messages', 'user', 'client', 'schools', 'admin_schools', 'school', 'clients', 'post', 'messages'));
 }
 public function __construct()
 {
     $this->schools = ['' => 'Select'] + School::where('is_active', 1)->lists('name', 'id')->all();
     $this->categories = ['' => 'Select'] + VideoCategory::where('is_active', 1)->where('type', 2)->lists('title', 'id')->all();
 }
Example #7
0
 public function clientPost($request, $client, $subject)
 {
     $name = $client->firstName . " " . $client->lastName;
     $school = School::where('username', $client->username)->first();
     return $this->send($request, $school, $name, $subject, $client);
 }
 public function getDelete($id)
 {
     $school = School::where(['id' => $id])->first()->delete();
     return Redirect::back();
 }
Example #9
0
 /**
  * Return the account of the admin
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  * @internal param User $user
  */
 public function getHome()
 {
     $user = \Auth::user();
     $admin_schools = null;
     $client_schools = null;
     $administrator = \App\Administrator::where('user_id', $user->id)->first();
     $clients = \App\Client::where('user_id', $user->id)->get();
     if ($administrator != null) {
         $admin_schools = \App\School::where('id', $administrator->school_id)->first();
     }
     //dd($client_schools);
     $schools = \Auth::user()->schools()->get();
     //dd($schools->count());
     return view('dashboard.index', compact('admin_schools', 'schools', 'clients'));
 }