Beispiel #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(SectionRequest $request)
 {
     $section = new Section();
     if ($request->hasFile('image')) {
         $image = $request->file('image')->getClientOriginalName();
         $request->file('image')->move('img/section/', $image);
     } else {
         $image = 'no-image';
     }
     $count = $section->count();
     if ($request->sort_id > 0) {
         $section->sort_id = $request->sort_id;
     } else {
         $section->sort_id = ++$count;
     }
     $section->service_id = $request->service_id;
     $section->title = $request->title;
     $section->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $section->image = $image;
     $section->title_description = $request->title_description;
     $section->meta_description = $request->meta_description;
     $section->text = $request->text;
     if ($request->status == 'on') {
         $section->status = 1;
     } else {
         $section->status = 0;
     }
     $section->save();
     return redirect('/admin/section')->with('status', 'Рубрика добавлена!');
 }
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|unique:sections|max:20']);
     if ($validator->fails()) {
         return Redirect::to('/admin/section')->withErrors($validator);
     }
     $section = new Section();
     $section->name = $request->name;
     $section->save();
     return Redirect::to('/admin/section');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $v = Validator::make(Request::all(), ['name' => 'required|max:50|unique:sections', 'desc' => 'required']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $section = new Section();
         $section->name = Request::get('name');
         $section->desc = Request::get('desc');
         $section->save();
         return redirect('sections');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(SectionRequest $request)
 {
     $section = new Section();
     $count = $section->count();
     if ($request->sort_id > 0) {
         $section->sort_id = $request->sort_id;
     } else {
         $section->sort_id = ++$count;
     }
     $section->service_id = $request->service_id;
     $section->title = $request->title;
     $section->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $section->lang = $request->lang;
     if ($request->status == 'on') {
         $section->status = 1;
     } else {
         $section->status = 0;
     }
     $section->save();
     return redirect('/admin/section')->with('status', 'Раздел добавлен!');
 }
 public function postsection()
 {
     //Section info post institute //saif for admin and insti
     $teacherid = Input::get('teacherName');
     $classid = Input::get('className');
     $sectionName = Input::get('SectionName');
     $sectionCategory = Input::get('sectioncategory');
     $sectionNote = Input::get('sectionNote');
     // return $classid;
     $teacherName = Teacher::where('teacher_id', '=', $teacherid)->where('institute_code', '=', Auth::user()->institute_id)->pluck('name');
     $className = ClassAdd::where('class_id', '=', $classid)->where('institute_code', '=', Auth::user()->institute_id)->pluck('class_name');
     $sec = new Section();
     $sec->institute_code = Auth::user()->institute_id;
     $sec->section_name = $sectionName;
     $sec->section_category = $sectionCategory;
     $sec->class_id = $classid;
     $sec->class_name = $className;
     $sec->tearcher_id = $teacherid;
     $sec->tearcher_name = $teacherName;
     $sec->note = $sectionNote;
     $sec->save();
     Session::flash('data', 'You successfully');
     return Redirect::to('sectionAdd');
 }
 public function postProfile(Request $request)
 {
     $userName = $request->input('name');
     $userEmail = $request->input('email');
     $userRealName = $request->input('realname');
     $userSchool = $request->input('userSchoolName');
     $userGrade = $request->input('userGrade');
     $userOrder = $request->input('userOrder');
     $userRole = $request->input('role');
     $userDescription = $request->input('userDescription');
     $currentUser = Auth::user();
     //update user info
     $currentUser->description = $userDescription;
     $currentUser->name = $userName;
     $currentUser->realname = $userRealName;
     $currentUser->email = $userEmail;
     $currentUser->role = $userRole;
     $section = Section::getSectionByGradeAndOrder($userGrade, $userOrder, $userSchool);
     //        find the matching section with grade and order.
     if (!$section) {
         //            means don't exist this section, please create a new Section.
         $newSection = new Section();
         $newSection->grade = $userGrade;
         $newSection->order = $userOrder;
         $newSection->schools_id = $userSchool;
         //            setting the number of the section
         $newSection->total += 1;
         $newSection->save();
     } else {
         //            add the 1 to total number of the exist section
         $section->total += 1;
     }
     //        先去teachingSection table中查找到用户的对应信息
     if ($userTeachingSection = TeachingSection::where()) {
         $currentUser->save();
     }
     //        the first method.
     /*        session()->flash('flash_message', '你的个人信息修改成功');
             session()->flash('flash_message_important', true);*/
     /*        return redirect('/dashboard')->with([
                 'flash_message' => '你的个人信息修改成功',
                 'flash_message_important' => true
             ]);*/
     //        \Flash::success()
     //        flash->success('你的个人信息修改成功');
     //        Flash::success('你的个人信息修改成功');
     //        flash()->success('你的个人信息修改成功');
     flash()->overlay('你的个人信息修改成功', '成功');
     return redirect('/dashboard');
 }
Beispiel #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validate entries
     // No entries to validate for a CV.
     //var_dump($request);
     //TODO change firstOr*** to ***
     // Create the CV first.
     $cv = $request->user()->cvs()->firstOrCreate(['name' => $request->name]);
     // Update the user's data.
     $request->user()->update(['surname' => $request->surname, 'lastname' => $request->lastname, 'address' => $request->address, 'telephone' => $request->telephone]);
     // Build the subsections first.
     $work = $request->user()->jobs()->firstOrNew(['name' => $request->enterprise, 'location' => $request->enterpriseAddress, 'title' => $request->job_name, 'description' => 'not filled yet', 'start_date' => $request->enterpriseBeginDate, 'end_date' => $request->enterpriseEndDate]);
     $education = $request->user()->educations()->firstOrNew(['name' => $request->school, 'location' => $request->schoolAddress, 'title' => $request->degree, 'description' => 'not filled yet', 'start_date' => $request->degreeBeginDate, 'end_date' => $request->degreeEndDate]);
     $language = $request->user()->languages()->firstOrNew(['name' => $request->language, 'level' => $request->languageLevel, 'creditation' => $request->languageDegree]);
     // New build the sections.
     $workSection = new Section(['type' => 'work']);
     $languageSection = new Section(['type' => 'language']);
     $educationSection = new Section(['type' => 'education']);
     // First attach the sections to the user
     $request->user()->sections()->saveMany([$workSection, $educationSection, $languageSection]);
     // Now attach them to the cv
     $cv->sections()->saveMany([$workSection, $educationSection, $languageSection]);
     // Now attach each section with it's correct subsection.
     $languageSection->language()->save($language);
     $language->save();
     $workSection->job()->save($work);
     $work->save();
     $educationSection->education()->save($education);
     $education->save();
     // Now save the sections.
     $workSection->save();
     $educationSection->save();
     $languageSection->save();
     return redirect('/cvs');
 }