public function store()
 {
     $school = new School();
     $school->name = Input::get('name');
     $school->kana = Input::get('kana');
     $school->save();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // read file
     $csv = Reader::createFromPath(storage_path($this->argument('file')));
     //get the first row, usually the CSV header
     $this->headers = collect($csv->fetchOne());
     // grab all rows
     $rows = $csv->setOffset(1)->fetchAll();
     // remove the last row if null
     if (!$rows[count($rows) - 1][0]) {
         array_pop($rows);
     }
     // loop them
     foreach ($rows as $row) {
         // map
         $school = School::firstOrNew(['name' => $row[$this->column('SchoolName')]]);
         $this->mapData($school, $row);
         // save
         if ($this->changes($school)) {
             $school->save();
         }
         $this->processed++;
     }
     $this->comment('Finished Schools Bulk Update');
     $this->comment('Processed: ' . $this->processed);
     $this->comment('Changed: ' . $this->changes);
 }
 public function schoolClicked($id)
 {
     $schools = School::all();
     $programs = Program::where('school_id', '=', $id)->get();
     $books = Book::where('school_id', '=', $id)->get();
     return view('home')->with('programs', $programs)->with('schools', $schools);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // get all the schools from database
     $schools = School::all();
     // call view by passing in all the schools as a variable call
     return view('schools.schoolshome', ['schools' => $schools]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     // use the Find class to get the school object with id.
     // get school object
     $schoolobj = School::find($id);
     // call view passing school object
     return view('students.studentshome', ['schoolobj' => $schoolobj]);
 }
Esempio n. 6
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function classroom()
 {
     foreach (Auth::user()->schools()->lists('school_id')->toArray() as $k => $v) {
         $value = $v;
     }
     $schools = School::find($value);
     $countUser = $schools->users->count();
     return view('principal/classroom', compact('countUser'));
 }
Esempio n. 7
0
 public function ajaxGetSchools(Request $request)
 {
     // if(Request::ajax()) {
     $schools = School::all();
     $schools_array = array();
     foreach ($schools as $key => $value) {
         $schools_array[] = $value;
     }
     return response()->json($schools_array);
     // }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('schools')->truncate();
     $school = new School();
     $school->name = '';
     $school->logo = '';
     $school->phone = '';
     $school->email = '';
     $school->swift_code = '';
     $school->line1 = '';
     $school->line2 = '';
     $school->line3 = '';
     $school->bank_id = 0;
     $school->account_name = '';
     $school->account_number = '';
     $school->promotion_avg = 0.0;
     $school->parent_discount = '';
     $school->staff_discount = '';
     $school->save();
 }
Esempio n. 9
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $pupil = Pupil::findOrFail($id);
     $schools = School::orderBy('name')->get();
     $schoolmapping = [];
     foreach ($schools as $school) {
         $schoolmapping[$school->id] = $school->name . ' (' . $school->town . ')';
     }
     $pupil->grade = $pupil->getGrade();
     return view('pupil.edit', ['pupil' => $pupil, 'schoolmapping' => $schoolmapping]);
 }
Esempio n. 10
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  CreateStaffRequest $request
  * 
  * @return \Illuminate\Http\Response
  */
 public function store(CreateStaffRequest $request)
 {
     $staff = User::create(['name' => ucwords($request->name), 'bday' => $request->bday, 'gender' => $request->gender, 'email' => $request->email, 'password' => bcrypt($request->password)]);
     $address = Address::create(['contact11' => $request->contact11]);
     $staff->addresses()->save($address);
     foreach (Auth::user()->schools()->lists('school_id')->toArray() as $k => $v) {
         $value = $v;
     }
     $school = School::find($value);
     $staff->schools()->attach($school);
     return redirect('principal/create#staff-tab')->withInput();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // remove any data from the table first
     School::truncate();
     // create 5 school objects
     $school1 = new School();
     $school1->schoolname = 'Wantirna';
     $school1->save();
     $school2 = new School();
     $school2->schoolname = 'Bayswater';
     $school2->save();
     $school3 = new School();
     $school3->schoolname = 'Scoresby';
     $school3->save();
     $school4 = new School();
     $school4->schoolname = 'Vermont';
     $school4->save();
     $school5 = new School();
     $school5->schoolname = 'Boronia';
     $school5->save();
 }
Esempio n. 12
0
 public function store(Request $request, $id = null)
 {
     $validator = Validator::make($request->all(), $this->school->rules);
     if ($validator->passes()) {
         if (isset($id)) {
             $school = $this->school->find($id);
         } else {
             $school = new School();
         }
         $school->school_name = $request->input('school_name');
         $school->contact_name = $request->input('contact_name');
         $school->phone = $request->input('phone');
         $school->email = $request->input('email');
         $school->website = $request->input('website');
         $school->application_url = $request->input('application_url');
         $school->save();
         return redirect()->to('schools')->with(['success' => 'School <span class="mono">' . $school->school_name . '</span> saved']);
     } else {
         return redirect()->back()->withInput()->withErrors($validator->messages());
     }
 }
 /**
  * Post from Step 1: School / Organization
  */
 public function post(Request $request)
 {
     if ($school = School::find($request->input('school'))) {
         // update school if advisor already in session
         if ($advisor = Session::get('advisor')) {
             $advisor->school_id = $school->id;
             $advisor->save();
         }
         Session::set('school', $school);
         return redirect('/event/' . Session::get('event')->slug . '/step/2');
     } else {
         return redirect('/event/' . Session::get('event')->slug . '/start');
     }
 }
Esempio n. 14
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'));
 }
Esempio n. 15
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  CreateStudentRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateStudentRequest $request)
 {
     $student = Student::create(['student' => ucwords($request->student), 'bday' => $request->bday, 'gender' => $request->gender, 'email' => $request->email]);
     $address = Address::create(['contact11' => $request->contact11]);
     $student->addresses()->save($address);
     foreach (Auth::user()->schools()->lists('school_id')->toArray() as $k => $v) {
         $value = $v;
     }
     $school = School::find($value);
     $grade = Grade::find($request->grade_id);
     $student->schools()->attach($school);
     $student->grades()->attach($grade);
     return redirect('principal/create#student-tab')->withInput();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // grab all School
     $schools = DB::table('School')->get();
     // migrate
     foreach ($schools as $school) {
         $new = new School();
         $new->region = $school->Region;
         $new->name = $school->SchoolName;
         $new->address = $school->Address;
         $new->city = $school->City;
         $new->state = $school->State;
         $new->zip = $school->Zip;
         $new->phone = $school->Phone;
         $new->votes = $school->Votes;
         $new->balance = $school->pastDue;
         if ($school->date) {
             $new->joined_at = new \Carbon\Carbon($school->date, 'America/New_York');
         } else {
             $new->joined_at = new \Carbon\Carbon('January 1 2014', 'America/New_York');
         }
         $new->save();
     }
 }
Esempio n. 17
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);
 }
Esempio n. 18
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 static function getAllSections()
 {
     //get a list of all sections.
     $sections = Section::paginate(5);
     $schools = array();
     $i = 0;
     if ($sections) {
         foreach ($sections as $section) {
             $school = School::getSchoolBySection($section);
             $section->setSchoolName($school->name);
             /*                $section->attribute['schoolId'] = $school->id;
                             $section->attribute['schoolName'] = $school->name;*/
             /*                $section[$i]['schoolId'] = $school->id;
                             $section[$i]['schoolName'] = $school->name;
                             $i++;*/
         }
     }
     return $sections;
 }
Esempio n. 20
0
 public function editSchool($id, Request $request)
 {
     $school = School::find($id);
     $school->bus = $request->input('bus');
     $school->save();
     if (Input::hasFile('images')) {
         $files = Input::file('images');
         foreach ($files as $file) {
             $destinationPath = 'uploads';
             $filename = $file->getClientOriginalName();
             $new_name = uniqid() . "." . File::extension($filename);
             $upload_success = $file->move(public_path() . "/" . $destinationPath, $new_name);
             $uploaded_files[] = $destinationPath . "/" . $new_name;
         }
         foreach ($uploaded_files as $file) {
             $photo = new Photo();
             $photo->school_id = $school->id;
             $photo->location = $file;
             $photo->save();
         }
     }
     return redirect(url('admin/school/' . $school->id))->with('success', 'Izmena je sacuvana');
 }
Esempio n. 21
0
 public function storeCMPost($row, $cm_id)
 {
     $content = ucfirst($row['first_name']) . ' ' . ucfirst($row['last_name']) . ' @ ' . \App\School::find($row['school_id'])->name;
     $img_url = $row['image_url'];
     // post save
     $post = $this->model->create(array('user_id' => $cm_id, 'content' => $content));
     $post->postGroups()->attach(\App\User::find($cm_id)->postGroups()->first()->id);
     // photo save
     $types = array('_s.', '_m.', '_l.');
     $sizes = array(100, 300, 600);
     $original_file_name = $img_url;
     $file_ext = 'jpg';
     $target_path = base_path() . '/public/imgs/';
     $hashSeed = "post" . $post->id . $original_file_name;
     while (1) {
         $file_name = \Func::getHashedValue($hashSeed);
         if (!\File::exists($target_path . \Func::getImgPath($file_name))) {
             break;
         }
         $hashSeed .= rand();
     }
     $target_path .= \Func::getImgPath($file_name) . '/';
     if (!\File::exists($target_path)) {
         \File::makeDirectory($target_path, 0775, true);
     }
     foreach ($types as $key => $type) {
         $new_name = $file_name . $type . $file_ext;
         $img = \Image::make($img_url);
         $img->resize($sizes[$key], null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save($target_path . $new_name);
         $img->destroy();
     }
     $this->photo->create(array('post_id' => $post->id, 'sequence' => 1, 'img_path' => $file_name . '.' . $file_ext));
     return $post->id;
 }
Esempio n. 22
0
 public function getUsers(Request $request)
 {
     $lat = $request->get('lat');
     $long = $request->get('long');
     $schools = School::all();
     $users = new \Illuminate\Database\Eloquent\Collection();
     for ($i = 0; $i < $schools->count(); $i++) {
         $schoolLat = $schools->get($i)->latitude;
         $schoolLong = $schools->get($i)->longitude;
         if ($this->haversine($lat, $long, $schoolLat, $schoolLong) < 50) {
             $users->push($schools->get($i)->usersNotVoted($request->get('CurrentUser')->id));
         }
     }
     return Response::json(['users' => $users->collapse()], 200);
 }
Esempio n. 23
0
 public function delete($id)
 {
     return School::delete($id);
 }
 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();
 }
 public function show($id)
 {
     return view('school.detail', ['school' => School::find($id)]);
 }
Esempio n. 26
0
 public function discount_policies(Request $request)
 {
     // dd($request);
     if (isset($request->parent_discount)) {
         $parent_discount = 1;
     } else {
         $parent_discount = 0;
     }
     if (isset($request->staff_discount)) {
         $staff_discount = 1;
     } else {
         $staff_discount = 0;
     }
     $school = School::find(1);
     $school->parent_discount = $parent_discount;
     $school->staff_discount = $staff_discount;
     $school->save();
     return redirect()->back();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     School::create(['region' => 'TEST', 'name' => 'Test School', 'address' => '123 Testing Lane', 'city' => 'Test City', 'state' => 'Test State', 'zip' => '12345', 'phone' => '1234567890', 'votes' => '5', 'balance' => '0', 'join_date' => '2015-10-16']);
     School::create(['region' => 'TEST2', 'name' => 'Test School 2', 'address' => '123 Testing Lane', 'city' => 'Test City', 'state' => 'Test State', 'zip' => '12345', 'phone' => '1234567890', 'votes' => '5', 'balance' => '0', 'join_date' => '2015-10-16']);
     School::create(['region' => 'TEST3', 'name' => 'Test School 3', 'address' => '123 Testing Lane', 'city' => 'Test City', 'state' => 'Test State', 'zip' => '12345', 'phone' => '1234567890', 'votes' => '5', 'balance' => '0', 'join_date' => '2015-10-16']);
 }
Esempio n. 28
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);
 }
Esempio n. 29
0
 public function change_logo(Requests\ChangePhotoRequest $request)
 {
     $extension = $request->avatar_file->getClientOriginalExtension();
     Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($request->avatar_file));
     $school = School::find($request->school);
     //$school->mime = $file->getClientMimeType();
     //$entry->original_filename = $file->getClientOriginalName();
     $school->logo = $file->getFilename() . '.' . $extension;
     $school->save();
     return \Redirect::route('school')->with('message', 'Logo successfuly Changed!');
 }
Esempio n. 30
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $school = \App\School::first();
     return view('reports.show')->with('title', 'SMS|REPORT')->with('school', $school);
 }