Esempio n. 1
0
 /**
  * Create a new authentication controller instance.
  *
  * @return void
  */
 public function __construct(Request $request)
 {
     $this->middleware('guest', ['except' => 'getLogout']);
     $favorites = ProfileController::getFavorites($request);
     view()->share('favorites', $favorites);
     User::detectUserLocation();
 }
Esempio n. 2
0
 /**
  * Get a validator for an incoming registration request.
  *
  * @param  array  $data
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function validator(array $input)
 {
     $rules = \App\Http\Controllers\ProfileController::getValidatorRules();
     $rules['password'] = '******';
     $user = new User($input);
     $data = $user->getAttributes();
     $data['password'] = $input['password'];
     $data['password_confirmation'] = $input['password_confirmation'];
     return Validator::make($data, $rules);
 }
Esempio n. 3
0
 public function __construct(Request $request)
 {
     $favorites = ProfileController::getFavorites($request);
     view()->share('favorites', $favorites);
 }
Esempio n. 4
0
 public function getSkillsData()
 {
     $profile = new ProfileController();
     return json_encode(array("results" => $profile->getSkills()));
 }
Esempio n. 5
0
 /**
  * Возвращает id незавершенного теста указанного уровня сложности
  * @param $levelId
  * @return null
  */
 private function currentTestId($levelId)
 {
     $query = 'SELECT id FROM tests WHERE profile_id = ' . ProfileController::profileId() . ' AND level_id = ' . $levelId . ' AND NOT is_passed;';
     $id = DB::select(DB::raw($query));
     if ($id) {
         return $id[0]->id;
     } else {
         return null;
     }
 }
Esempio n. 6
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'));
 }
Esempio n. 7
0
 /**
  * Возвращает достижения пользователя
  * @return null
  */
 public function getAchievements()
 {
     $query = 'SELECT achievements.id as id, name, description, is_checked FROM achievements
               JOIN users_achievements ON achievements.id = users_achievements.achievement_id
               WHERE profile_id  = ' . ProfileController::profileId() . ';';
     $achievements = DB::select(DB::raw($query));
     if ($achievements) {
         $data = array();
         foreach ($achievements as $achievement) {
             array_push($data, (array) $achievement);
         }
         return $achievements;
     } else {
         return null;
     }
 }