/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(SectionRequest $request, $id)
 {
     $section = Section::findOrFail($id);
     $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', 'Раздел обновлен!');
 }
Beispiel #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(SectionRequest $request, $id)
 {
     $section = Section::findOrFail($id);
     if ($request->hasFile('image')) {
         $image = $request->file('image')->getClientOriginalName();
         $request->file('image')->move('img/section/', $image);
         if (Storage::exists('img/section/' . $section->image)) {
             Storage::delete('img/section/' . $section->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);
     if (isset($image)) {
         $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 recordstudentEachSectionEachTest($studentId, $newExaminationId)
 {
     /*        $teachingSections = TeachingSection::where('sections_id', '=', $sectionId)->get();
     
             $studentsIdsIncludingTeachers = DB::table('teaching_sections')->where('sections_id', '=', $sectionId)->lists('users_id');
             $students = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIdsIncludingTeachers)->get();
             $studentsIds = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIdsIncludingTeachers)->lists('id');*/
     //        dd($students);
     //        dd($sectionId);
     //        dd($newExaminationId);
     //generating a transcript table for each student in this examination.
     $newTranscript = new Transcript();
     $newTranscript->examinations_id = $newExaminationId;
     $newTranscript->users_id = $studentId;
     $newTranscript->save();
     $student = User::findOrFail($studentId);
     $teachingSection = TeachingSection::getTeachingsectionByStudent($student);
     $section = Section::findOrFail($teachingSection->sections_id);
     $school = School::findOrFail($section->schools_id);
     $studentArray = array();
     $studentArray['name'] = $student->name;
     $studentArray['realname'] = $student->realname;
     $studentArray['sectionGrade'] = $section->grade;
     $studentArray['sectionOrder'] = $section->order;
     $studentArray['schoolName'] = $school->name;
     //        $students = DB::table('users')->where('role', '=', '1')->whereIn('id', $studentsIds)->paginate(10);
     //        $wholeSectionTranscripts = DB::table('transcripts')->where('examinations_id', '=', $newExaminationId)->whereIn('users_id', $studentsIds)->paginate(10);
     /*       if (Session::has('backUrl')) {
                 Session::keep('backUrl');
             }*/
     return view('scores.logStudentsTestResult', compact('newTranscript', 'studentArray'));
 }
Beispiel #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(PostRequest $request)
 {
     $section = Section::findOrFail($request->section_id);
     $introImage = null;
     $images = [];
     if ($request->hasFile('images')) {
         $i = 0;
         foreach ($request->file('images') as $key => $image) {
             if (isset($image)) {
                 $imageName = $key . '-image-' . str_random(10) . '.' . $image->getClientOriginalExtension();
                 if (!file_exists('img/posts/' . Auth::id())) {
                     Storage::makeDirectory('img/posts/' . Auth::id());
                 }
                 if ($i == 0) {
                     $i++;
                     $mainFile = Image::canvas(300, 200, '#ffffff');
                     $introFile = Image::make($image);
                     $this->file = $introFile;
                     $this->optimalResize(300, 200);
                     $mainFile->insert($this->file, 'center');
                     $mainFile->rectangle(0, 0, 299, 199, function ($draw) {
                         $draw->border(1, '#dddddd');
                     });
                     $mainFile->save('img/posts/' . Auth::id() . '/main-' . $imageName);
                     $introImage = 'main-' . $imageName;
                 }
                 // Creating images
                 $moreFile = Image::canvas(634, 432, '#ffffff');
                 $file = Image::make($image);
                 $this->file = $file;
                 $this->optimalResize(634, 432);
                 $moreFile->insert($this->file, 'center');
                 $moreFile->insert('img/watermark-blue.png', 'bottom-left', 10, 10);
                 $moreFile->rectangle(0, 0, 633, 431, function ($draw) {
                     $draw->border(1, '#dddddd');
                 });
                 $moreFile->save('img/posts/' . Auth::id() . '/' . $imageName);
                 // Creating mini images
                 $miniFile = Image::canvas(95, 71, '#ffffff');
                 $this->file = $file;
                 $this->optimalResize(95, 71);
                 $miniFile->insert($this->file, 'center');
                 $miniFile->rectangle(0, 0, 94, 70, function ($draw) {
                     $draw->border(1, '#dddddd');
                 });
                 $miniFile->save('img/posts/' . Auth::id() . '/mini-' . $imageName);
                 $images[$key]['image'] = $imageName;
                 $images[$key]['mini_image'] = 'mini-' . $imageName;
             }
         }
     }
     $post = new Post();
     $post->user_id = Auth::id();
     $post->city_id = $request->city_id;
     $post->section_id = $request->section_id;
     $post->slug = str_slug($request->title);
     $post->title = $request->title;
     $post->price = $request->price;
     if ($request->deal) {
         $post->deal = $request->deal;
     }
     $post->description = $request->description;
     $post->image = $introImage;
     $post->images = serialize($images);
     $post->address = $request->address;
     $post->phone = $request->phone;
     $post->email = $request->email;
     $post->comment = $request->comment;
     $post->save();
     return redirect('my_posts')->with('status', 'Объявление добавлено!');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\Sections\EditSectionRequest $request, $id, StoreFile $storeFile, \App\Section $section)
 {
     if ($request->hasFile('image')) {
         //Creating and moving the file image
         $image_path = $storeFile->move($request->file('image'), 'public/images/sections/', 16);
         //Adding the image file path to the array of request
         $modified_request = array_merge($request->except('image'), ['image' => $image_path]);
     } else {
         $modified_request = $request->except('image');
     }
     //Storing
     $section->findOrFail($id)->update($modified_request);
     //Redirect
     return redirect()->action('Panel\\SectionsController@index');
 }