public function index()
 {
     $sections = Section::all();
     if (Auth::user()) {
         $cart = Auth::user()->cart;
     } else {
         $cart = new Collection();
         if (Session::has('cart')) {
             foreach (Session::get('cart') as $item) {
                 $elem = new Cart();
                 $elem->product_id = $item['product_id'];
                 $elem->amount = $item['qty'];
                 if (isset($item['options'])) {
                     $elem->options = $item['options'];
                 }
                 $cart->add($elem);
             }
         }
     }
     $total = 0;
     $options = new Collection();
     foreach ($cart as $item) {
         $total += $item->product->price * $item->amount;
         if ($item->options) {
             $values = explode(',', $item->options);
             foreach ($values as $value) {
                 $options->add(OptionValue::find($value));
             }
         }
     }
     return view('site.cart', compact('sections', 'total', 'cart', 'options'));
 }
 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function showRegistrationForm()
 {
     // Get the list of departments
     $departmentArr = Department::all();
     // Get the list of sections
     $sectionArr = Section::all();
     return view($this->registerView)->with(['departments' => $departmentArr, 'sections' => $sectionArr]);
 }
 public function profile()
 {
     $user = Auth::User();
     $sections = null;
     $school = null;
     $teachingSections = null;
     $allSchools = School::all()->orderBy('id');
     $allSections = Section::all();
     $i = 0;
     if ($user->role == 1) {
         $studentSection = TeachingSection::getTeachingsectionByStudent($user);
         if ($studentSection === null) {
         } else {
             $school = School::getSchoolBySection($studentSection);
         }
         return view('users.profile', compact('school', 'user', 'studentSection'));
     } elseif ($user->role == 2) {
         $teacherTeachingSections = TeachingSection::getTeachingsectionsByTeacher($user);
         //$teacherSections有多个teachingSection
         if ($teacherTeachingSections === null) {
         } else {
             $teachedSections = [];
             foreach ($teacherTeachingSections as $teacherTeachingSection) {
                 $section = Section::find($teacherTeachingSection->sections_id);
                 $teachedSections[i] = $section;
                 $i++;
             }
             $school = School::getSchoolBySection($teachedSections[0]);
             return view('users.profile', compact('school', 'user', 'teachedSections'));
         }
     } else {
         return view('users.newUserProfile', compact('user'));
     }
     //如果这个学生没有关联任何班级
     $teachingSections = TeachingSection::getTeachingsectionsByUser($user);
     if ($teachingSections) {
         $sections = Section::getSectionByteachingSections($teachingSections);
         $school = School::getSchoolBySection($sections);
         return view('users.profile', compact('school', 'user', 'sections'));
     } else {
         return view('users.profile', compact('school', 'user', 'sections'));
     }
     //        $sections_id = $teachingSections->id;
     //        print_r($sections_id);
     //        $sections = Section::getSectionByteachingSections($teachingSections);
     //        $school = School::getSchoolBySection($sections);
     //        容错设计
     //        echo '--------------------------';
     //        echo '--------------------------';
     //        print_r($schoolName);
     //        print_r($teachingSections->id);
     //        print_r($teachingSections->sections_id);
     //        print_r($teachingSections);
     //         return view('users.profile', compact('user'));
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     if (Schema::hasTable('sections')) {
         $sections = Section::all();
         $pages = Page::all();
         $pagesNew = [];
         $sectionsNew = [];
         view()->share(['sections' => $sections, 'pages' => $pages, 'sectionsNew' => $sectionsNew, 'pagesNew' => $pagesNew]);
     }
 }
 public static function getPageInfo(&$sections, &$cart, &$total)
 {
     $sections = Section::all();
     if (Auth::user()) {
         $cart = Auth::user()->cart;
     } else {
         $cart = new Collection();
         if (Session::has('cart')) {
             foreach (Session::get('cart') as $item) {
                 $elem = new Cart();
                 $elem->product_id = $item['product_id'];
                 $elem->amount = $item['qty'];
                 if (isset($item['options'])) {
                     $elem->options = $item['options'];
                 }
                 $cart->add($elem);
             }
         }
     }
     $total = 0;
     foreach ($cart as $item) {
         $total += $item->product->price * $item->amount;
     }
 }
 public function editCategory($id)
 {
     $category = Category::find($id);
     $sections = Section::all();
     return view('admin.editCategory', compact('category', 'sections'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $sections = Section::all();
     return view('sections.index', compact('sections'));
 }
 /**
  * Show the sections currently present in the database
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function manageSections()
 {
     $sectionArr = Section::all();
     $departmentArr = Department::all();
     return view('admin.manage.sections', ['sections' => $sectionArr, 'count' => 0, 'departments' => $departmentArr]);
 }
 public function getSections()
 {
     $result = Section::all();
     return response()->json(['sections' => $result]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $tag = Tag::findOrFail($id);
     $section = Section::all();
     return view('admin.tags.edit', compact('tag', 'section'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $profile = Profile::findOrFail($id);
     $section = Section::all();
     return view('admin.users.edit', compact('profile', 'section'));
 }
 public function getRegister()
 {
     $sections = Section::all();
     if (Auth::user()) {
         $cart = Auth::user()->cart;
     } else {
         $cart = new Collection();
         if (Session::has('cart')) {
             foreach (Session::get('cart') as $item) {
                 $elem = new Cart();
                 $elem->product_id = $item['product_id'];
                 $elem->amount = $item['qty'];
                 if (isset($item['options'])) {
                     $elem->options = $item['options'];
                 }
                 $cart->add($elem);
             }
         }
     }
     $total = 0;
     foreach ($cart as $item) {
         $total += $item->product->price * $item->amount;
     }
     return view('auth.register', compact('sections', 'cart', 'total'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $section = Section::find(Crypt::decrypt($id));
     if (count($section) == 0) {
         return response()->json(['success' => false, 'message' => 'Invalid id!']);
     }
     $student = Student::where('section_id', Crypt::decrypt($id))->first();
     if (count($student) > 0) {
         $sections = Section::all();
         return response()->json(['success' => false, 'message' => 'Cannot delete section. A student is enrolled in this section', 'content' => view('partials.section-table', compact('sections'))->render()]);
     }
     if (!$section->delete()) {
         return response()->json(['success' => false, 'message' => 'Failed to delete record!']);
     }
     $sections = Section::all();
     return response()->json(['success' => true, 'message' => 'Delete record successful!', 'content' => view('partials.section-table', compact('sections'))->render()]);
 }
Exemple #14
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Post::paginate(20);
     $sections = Section::all();
     return view('admin.posts.index', compact('posts', 'sections'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $student = Student::find(Crypt::decrypt($id));
     $sections = Section::all();
     return view('students.create', compact('student', 'sections'));
 }
 public function index()
 {
     $sections = Section::all();
     return view('admin.section.index', compact('sections'));
 }
Exemple #17
0
 public function filterPosts(Request $request)
 {
     $query = $request->city_id ? 'city_id = ' . (int) $request->city_id . ' AND ' : NULL;
     $query .= $request->image == 'on' ? 'image IS NOT NULL AND ' : NULL;
     $query .= $request->from ? 'price >= ' . (int) $request->from . ' AND ' : 'price >= 0 AND ';
     $query .= $request->to ? 'price <= ' . (int) $request->to : 'price <= 9999999999';
     if ($request->text) {
         $text = trim(strip_tags($request->text));
         $query .= " AND (title LIKE '%{$text}%' or description LIKE '%{$text}%')";
     }
     $section = Section::all();
     $profiles = Profile::take(5)->get();
     if ($request->category_id) {
         $section = Section::find($request->category_id);
         $posts = Post::where('status', 1)->where('category_id', $request->category_id)->whereRaw($query)->orderBy('id', 'DESC')->paginate(10);
         $posts->appends(['category_id' => (int) $request->category_id, 'city_id' => (int) $request->city_id, 'text' => $request->text, 'image' => $request->image == 'on' ? 'on' : NULL, 'from' => (int) $request->from, 'to' => (int) $request->to, 'tag_id' => $request->tags_id]);
     } else {
         $posts = Post::where('status', 1)->whereRaw($query)->orderBy('id', 'DESC')->paginate(10);
         $posts->appends(['city_id' => (int) $request->city_id, 'text' => $request->text, 'image' => $request->image == 'on' ? 'on' : NULL, 'from' => (int) $request->from, 'to' => (int) $request->to, 'tag_id' => $request->tags_id]);
     }
     $selected_tags = [];
     if (isset($request->tags_id)) {
         $selected_tags = $request->tags_id;
         foreach ($posts as $post_key => $post) {
             $hasTag = false;
             foreach ($selected_tags as $tag_id) {
                 if ($post->hasTag($tag_id)) {
                     $hasTag = true;
                 }
             }
             if (!$hasTag) {
                 unset($posts[$post_key]);
             }
         }
     }
     $category = Category::findOrFail($request->category_id);
     $category_tags = $category->tags()->get();
     $favorites = ProfileController::getFavorites($request);
     $favorites = $favorites ? $favorites : [];
     return view('board.posts', compact('category', 'category_tags', 'selected_tags', 'section', 'sections', 'profiles', 'posts', 'favorites'));
 }
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $sections = Section::all();
     return view('section.index', ['sections' => $sections]);
 }
Exemple #19
0
 public function filterPosts(Request $request)
 {
     $query = $request->city_id ? 'city_id = ' . (int) $request->city_id . ' AND ' : NULL;
     $query .= $request->image == 'on' ? 'image IS NOT NULL AND ' : NULL;
     $query .= $request->from ? 'price >= ' . (int) $request->from . ' AND ' : 'price >= 0 AND ';
     $query .= $request->to ? 'price <= ' . (int) $request->to : 'price <= 9999999';
     if ($request->text) {
         $text = trim(strip_tags($request->text));
         $query .= " AND (title LIKE '%{$text}%' or description LIKE '%{$text}%')";
     }
     $sections = Section::all();
     $profiles = Profile::take(5)->get();
     if ($request->section_id) {
         $section = Section::find($request->section_id);
         $posts = Post::where('status', 1)->where('section_id', $request->section_id)->whereRaw($query)->orderBy('id', 'DESC')->paginate(10);
         $posts->appends(['section_id' => (int) $request->section_id, 'city_id' => (int) $request->city_id, 'text' => $request->text, 'image' => $request->image == 'on' ? 'on' : NULL, 'from' => (int) $request->from, 'to' => (int) $request->to]);
     } else {
         $posts = Post::where('status', 1)->whereRaw($query)->orderBy('id', 'DESC')->paginate(10);
         $posts->appends(['city_id' => (int) $request->city_id, 'text' => $request->text, 'image' => $request->image == 'on' ? 'on' : NULL, 'from' => (int) $request->from, 'to' => (int) $request->to]);
     }
     return view('board.found_posts', compact('section', 'sections', 'profiles', 'posts'));
 }