Example #1
0
 /**
  * Store a new school.
  *
  * @param AddSchoolFormRequest $request
  * @return Response
  */
 public function addSchool(AddSchoolFormRequest $request)
 {
     $school = School::create(['name' => $request->school, 'town_id' => $request->town]);
     $user = new AuthController();
     $data = $request->all();
     $data['class'] = -1;
     $data['role'] = 1;
     $data['school'] = $school->id;
     $data['is_moderated'] = 1;
     $user->create($data);
     return redirect(route('home'));
 }
 /**
  * Create new usertype
  *
  * @return Response
  */
 public function saveSchool(Request $request)
 {
     //Validate the Request
     $this->validate($request, ['name' => 'required', 'location' => 'required', 'contact_person' => 'required', 'address' => 'required', 'image' => 'image']);
     if (isset($request['image'])) {
         $imageName = $request['name'] . '.' . $request['image']->getClientOriginalExtension();
         $location = 'staticPages/images/schools/' . $request['location'] . '/';
         $request['image']->move($location, $imageName);
         $request['image_path'] = url($location . $imageName);
         $request['thumbnail_path'] = url($location . $imageName);
     } else {
         $request['image_path'] = url('staticPages/images/schools/commingsoonBig.jpg');
         $request['thumbnail_path'] = url('staticPages/images/schools/commingsoon.jpg');
     }
     $school = School::create($request->except('image'));
     \Session::flash('flash_message', $school->name . " " . $school->location . ' has been created!');
     \Session::flash('flash_message_level', 'success');
     return Redirect::to('admin/school');
 }
Example #3
0
 public function run()
 {
     DB::table('schools')->delete();
     School::create(['name' => 'Вінницька гімназія', 'town_id' => 2]);
     School::create(['name' => 'Дережицька СЗШ', 'town_id' => 1]);
 }